This commit is contained in:
John Kerl 2015-11-10 08:07:57 -05:00
parent 91ac227b69
commit 88a53de03c
8 changed files with 71 additions and 18 deletions

View file

@ -41,7 +41,8 @@ static void mapper_filter_usage(FILE* o, char* argv0, char* verb) {
fprintf(o, " %s %s '($x<.5 && $y<.5) || ($x>.5 && $y>.5)'\n", argv0, verb);
fprintf(o, " %s %s '($name =~ \"^sys.*east$\") || ($name =~ \"^dev.[0-9]+\"i)'\n", argv0, verb);
fprintf(o, "Please see http://johnkerl.org/miller/doc/reference.html for more information\n");
fprintf(o, "including function list.\n");
fprintf(o, "including function list. Or \"%s -f\". Please also also \"%s grep\" which is\n", argv0, argv0);
fprintf(o, "useful when you don't yet know which field name(s) you're looking for.\n");
}
// ----------------------------------------------------------------

View file

@ -79,16 +79,20 @@ static sllv_t* mapper_sec2gmt_process(lrec_t* pinrec, context_t* pctx, void* pvs
if (sval == NULL)
continue;
double dval = mlr_double_from_string_or_die(sval);
if (*sval == 0) {
lrec_put_no_free(pinrec, name, "");
} else {
double dval = mlr_double_from_string_or_die(sval);
// xxx make mlrutil func
time_t clock = (time_t) dval;
struct tm tm;
struct tm *ptm = gmtime_r(&clock, &tm);
char* stamp = mlr_malloc_or_die(32);
(void)strftime(stamp, 32, "%Y-%m-%dT%H:%M:%SZ", ptm);
// xxx make mlrutil func
time_t clock = (time_t) dval;
struct tm tm;
struct tm *ptm = gmtime_r(&clock, &tm);
char* stamp = mlr_malloc_or_die(32);
(void)strftime(stamp, 32, "%Y-%m-%dT%H:%M:%SZ", ptm);
lrec_put_no_free(pinrec, name, stamp);
lrec_put(pinrec, name, stamp, LREC_FREE_ENTRY_VALUE);
}
}
return sllv_single(pinrec);
}

View file

@ -16,6 +16,30 @@ a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864
mlr cat /dev/null
mlr cat -n ./reg_test/input/abixy
n=0,a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
n=1,a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
n=2,a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
n=3,a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
n=4,a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
n=5,a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697
n=6,a=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694
n=7,a=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006
n=8,a=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059
n=9,a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864
mlr cat -N counter ./reg_test/input/abixy
counter=0,a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
counter=1,a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
counter=2,a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
counter=3,a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
counter=4,a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
counter=5,a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697
counter=6,a=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694
counter=7,a=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006
counter=8,a=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059
counter=9,a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864
mlr cut -f a,x ./reg_test/input/abixy
a=pan,x=0.3467901443380824
a=eks,x=0.7586799647899636
@ -582,6 +606,20 @@ a=zee,b=wye,count=2
a=hat,b=wye,count=2
a=pan,b=wye,count=2
mlr grep pan ./reg_test/input/abixy-het
a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=pan,i=5,xxx=0.5732889198020006,y=0.8636244699032729
a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697
a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864
mlr grep -v pan ./reg_test/input/abixy-het
aaa=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,bbb=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=eks,b=zee,iii=7,x=0.6117840605678454,y=0.1878849191181694
a=zee,b=wye,i=8,x=0.5985540091064224,yyy=0.976181385699006
aaa=hat,bbb=wye,i=9,x=0.03144187646093577,y=0.7495507603507059
================================================================
SORT

View file

@ -76,6 +76,9 @@ announce STATELESS MAPPERS
run_mlr cat $indir/abixy
run_mlr cat /dev/null
run_mlr cat -n $indir/abixy
run_mlr cat -N counter $indir/abixy
run_mlr cut -f a,x $indir/abixy
run_mlr cut --complement -f a,x $indir/abixy
@ -165,6 +168,9 @@ run_mlr uniq -c -g a,b $indir/abixy-het
run_mlr count-distinct -f a $indir/small $indir/abixy
run_mlr count-distinct -f a,b $indir/small $indir/abixy
run_mlr grep pan $indir/abixy-het
run_mlr grep -v pan $indir/abixy-het
# ----------------------------------------------------------------
announce SORT

View file

@ -17,17 +17,13 @@ TOP OF LIST
- brew version bump?!?
- cut a release w/ manpage
! formats @ mlrdoc -- note default iidx for ps-less dkvp fields. also @ mlr -h?
! mlrdoc/formats -- note default iidx for ps-less dkvp fields. also @ mlr -h?
! split mlrdoc into master & releases -- ?
* new UT:
o sec2gmt
o cat -n/-N
o grep
! grep to mld regex section
! mlr grep -h {pattern} -> {regex}
! need mlr --regex-help re //, "...", "..."i, "\(..\)" vs. "(..)", etc.
* sec2gmt verb&fcn null-handling & UT both
* R:
! xref @ covers x 2
@ -52,6 +48,8 @@ TOP OF LIST
- out-of-place bar -- preserving count as separate column?
- fix # for just-above-lo bar: "[...]" & "<...]" & "[...>" ?
! need mlr --regex-help re //, "...", "..."i, "\(..\)" vs. "(..)", etc.
* faqents:
! some of these putative faqents (and maybe some of the existing ones) should be in a cookbook page
- csv/csvlite compare/contrast @ mld formats

View file

@ -244,6 +244,8 @@ filter '$url =~ "http.*com"'</tt>
<li/> In <tt>mlr rename</tt>, e.g. <tt>mlr rename -r '^(sda[0-9]).*$,dev/\1'</tt>
<li/> In <tt>mlr grep</tt>, e.g. <tt>mlr --csv grep 00188555487 myfiles*.csv</tt>
</ul>
<p/>The <tt>i</tt> after the double-quoted regular-expression string is used to

View file

@ -1,7 +1,7 @@
'\" t
.\" Title: mlr
.\" Author: [see the "AUTHOR" section]
.\" Generator: mkman.rb
.\" Generator: ./mkman.rb
.\" Date: 2015-11-10
.\" Manual: \ \&
.\" Source: \ \&
@ -371,7 +371,8 @@ Examples:
mlr filter '($x<.5 && $y<.5) || ($x>.5 && $y>.5)'
mlr filter '($name =~ "^sys.*east$") || ($name =~ "^dev.[0-9]+"i)'
Please see http://johnkerl.org/miller/doc/reference.html for more information
including function list.
including function list. Or "mlr -f". Please also also "mlr grep" which is
useful when you don't yet know which field name(s) you're looking for.
.fi
.if n \{\
.RE

View file

@ -651,6 +651,8 @@ filter '$url =~ "http.*com"'</tt>
<li/> In <tt>mlr rename</tt>, e.g. <tt>mlr rename -r '^(sda[0-9]).*$,dev/\1'</tt>
<li/> In <tt>mlr grep</tt>, e.g. <tt>mlr --csv grep 00188555487 myfiles*.csv</tt>
</ul>
<p/>The <tt>i</tt> after the double-quoted regular-expression string is used to
@ -989,7 +991,8 @@ Examples:
mlr filter '($x&lt;.5 &amp;&amp; $y&lt;.5) || ($x&gt;.5 &amp;&amp; $y&gt;.5)'
mlr filter '($name =~ "^sys.*east$") || ($name =~ "^dev.[0-9]+"i)'
Please see http://johnkerl.org/miller/doc/reference.html for more information
including function list.
including function list. Or "mlr -f". Please also also "mlr grep" which is
useful when you don't yet know which field name(s) you're looking for.
</pre>
</div>
<p/>