From 6f8dd97afbe8ffad767516cc85a46b7c503c2b65 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 26 Aug 2018 16:25:52 -0400 Subject: [PATCH] new altkv verb --- c/cli/mlrcli.c | 1 + c/mapping/Makefile.am | 1 + c/mapping/mappers.h | 1 + c/reg_test/expected/out | 6 +++++ c/reg_test/run | 7 ++++++ doc/content-for-reference-verbs.html | 13 ++++++++++ doc/manpage.html | 6 ++++- doc/manpage.txt | 6 ++++- doc/mlr.1 | 12 +++++++++- doc/reference-verbs.html | 36 ++++++++++++++++++++++++++++ doc/reference.html | 10 ++++---- 11 files changed, 91 insertions(+), 8 deletions(-) diff --git a/c/cli/mlrcli.c b/c/cli/mlrcli.c index 8ae71c108..de370b3f7 100644 --- a/c/cli/mlrcli.c +++ b/c/cli/mlrcli.c @@ -38,6 +38,7 @@ // ---------------------------------------------------------------- static mapper_setup_t* mapper_lookup_table[] = { + &mapper_altkv_setup, &mapper_bar_setup, &mapper_bootstrap_setup, &mapper_cat_setup, diff --git a/c/mapping/Makefile.am b/c/mapping/Makefile.am index 02ee9219c..ea1d2747c 100644 --- a/c/mapping/Makefile.am +++ b/c/mapping/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES= libmapping.la libmapping_la_SOURCES= \ mapper.h \ + mapper_altkv.c \ mapper_bar.c \ mapper_bootstrap.c \ mapper_cat.c \ diff --git a/c/mapping/mappers.h b/c/mapping/mappers.h index 815864994..06167a64b 100644 --- a/c/mapping/mappers.h +++ b/c/mapping/mappers.h @@ -4,6 +4,7 @@ #include "containers/slls.h" #include "mapping/mapper.h" +extern mapper_setup_t mapper_altkv_setup; extern mapper_setup_t mapper_bar_setup; extern mapper_setup_t mapper_bootstrap_setup; extern mapper_setup_t mapper_cat_setup; diff --git a/c/reg_test/expected/out b/c/reg_test/expected/out index fa085e5f8..9b9f70789 100644 --- a/c/reg_test/expected/out +++ b/c/reg_test/expected/out @@ -468,6 +468,12 @@ zee wye 8 [0.0314419]*******...[0.75868] [0.134189]*********#[0.976181] hat wye 9 [0.0314419]#.........[0.75868] [0.134189]*******...[0.976181] pan wye 10 [0.0314419]******....[0.75868] [0.134189]*********.[0.976181] +mlr altkv +a=b,c=d,e=f + +mlr altkv +a=b,c=d,e=f,4=g + ================================================================ TRIVIAL RETAINERS diff --git a/c/reg_test/run b/c/reg_test/run index d465b1c8c..efc16f57e 100755 --- a/c/reg_test/run +++ b/c/reg_test/run @@ -213,6 +213,13 @@ run_mlr --opprint bar -f x,y --lo 0 --hi 1 $indir/abixy run_mlr --opprint bar -f x,y -c c -x x -b b --lo 0.1 --hi 0.9 -w 20 $indir/abixy run_mlr --opprint bar --auto -f x,y -w 10 $indir/abixy +run_mlr altkv <here. + + +

altkv

+ +
+ +

Map list of values to alternating key/value pairs. + +POKI_RUN_COMMAND{{mlr altkv -h}}HERE + +POKI_RUN_COMMAND{{echo 'a,b,c,d,e,f' mlr --opprint altkv}}HERE +POKI_RUN_COMMAND{{echo 'a,b,c,d,e,f,g' mlr --opprint altkv}}HERE +

bar

diff --git a/doc/manpage.html b/doc/manpage.html index 967489b32..285e2bc9b 100644 --- a/doc/manpage.html +++ b/doc/manpage.html @@ -319,7 +319,7 @@ OPTIONS -K Show a bare listing of keywords by name. VERB LIST - bar bootstrap cat check count-distinct count-similar cut decimate filter + altkv bar bootstrap cat check count-distinct count-similar cut decimate filter fraction grep group-by group-like having-fields head histogram join label least-frequent merge-fields most-frequent nest nothing put regularize rename reorder repeat reshape sample sec2gmt sec2gmtdate seqgen shuffle sort stats1 @@ -580,6 +580,10 @@ OPTIONS For more information, please invoke mlr {subcommand} --help VERBS + altkv + Usage: mlr altkv [no options] + Given fields with values of the form a,b,c,d,e,f emits a=b,c=d,e=f pairs. + bar Usage: mlr bar [options] Replaces a numeric field with a number of asterisks, allowing for cheesy diff --git a/doc/manpage.txt b/doc/manpage.txt index e474b5f85..a9943c964 100644 --- a/doc/manpage.txt +++ b/doc/manpage.txt @@ -125,7 +125,7 @@ OPTIONS -K Show a bare listing of keywords by name. VERB LIST - bar bootstrap cat check count-distinct count-similar cut decimate filter + altkv bar bootstrap cat check count-distinct count-similar cut decimate filter fraction grep group-by group-like having-fields head histogram join label least-frequent merge-fields most-frequent nest nothing put regularize rename reorder repeat reshape sample sec2gmt sec2gmtdate seqgen shuffle sort stats1 @@ -386,6 +386,10 @@ OPTIONS For more information, please invoke mlr {subcommand} --help VERBS + altkv + Usage: mlr altkv [no options] + Given fields with values of the form a,b,c,d,e,f emits a=b,c=d,e=f pairs. + bar Usage: mlr bar [options] Replaces a numeric field with a number of asterisks, allowing for cheesy diff --git a/doc/mlr.1 b/doc/mlr.1 index b8b653cb1..1e61176ec 100644 --- a/doc/mlr.1 +++ b/doc/mlr.1 @@ -168,7 +168,7 @@ output separator to the given value. .RS 0 .\} .nf - bar bootstrap cat check count-distinct count-similar cut decimate filter + altkv bar bootstrap cat check count-distinct count-similar cut decimate filter fraction grep group-by group-like having-fields head histogram join label least-frequent merge-fields most-frequent nest nothing put regularize rename reorder repeat reshape sample sec2gmt sec2gmtdate seqgen shuffle sort stats1 @@ -505,6 +505,16 @@ For more information, please invoke mlr {subcommand} --help .SH "VERBS" .sp +.SS "altkv" +.if n \{\ +.RS 0 +.\} +.nf +Usage: mlr altkv [no options] +Given fields with values of the form a,b,c,d,e,f emits a=b,c=d,e=f pairs. +.fi +.if n \{\ +.RE .SS "bar" .if n \{\ .RS 0 diff --git a/doc/reference-verbs.html b/doc/reference-verbs.html index 8073b9575..b4212cf70 100644 --- a/doc/reference-verbs.html +++ b/doc/reference-verbs.html @@ -189,6 +189,7 @@ Miller commands were run with pretty-print-tabular output format.
Contents:
• Overview
+• altkv
• bar
• bootstrap
• cat
@@ -303,6 +304,41 @@ a=wye,x_sum=0.777892 +
+ +

altkv

+ +
+ +

Map list of values to alternating key/value pairs. + +

+

+
+$ mlr altkv -h
+Usage: mlr altkv [no options]
+Given fields with values of the form a,b,c,d,e,f emits a=b,c=d,e=f pairs.
+
+
+

+ +

+

+
+$ echo 'a,b,c,d,e,f' mlr --opprint altkv
+a,b,c,d,e,f mlr --opprint altkv
+
+
+

+

+

+
+$ echo 'a,b,c,d,e,f,g' mlr --opprint altkv
+a,b,c,d,e,f,g mlr --opprint altkv
+
+
+

+

bar

diff --git a/doc/reference.html b/doc/reference.html index fbabe3fa8..0c30830c8 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -1439,11 +1439,11 @@ Help options: -K Show a bare listing of keywords by name. Verbs: - bar bootstrap cat check count-distinct count-similar cut decimate filter - fraction grep group-by group-like having-fields head histogram join label - least-frequent merge-fields most-frequent nest nothing put regularize rename - reorder repeat reshape sample sec2gmt sec2gmtdate seqgen shuffle sort stats1 - stats2 step tac tail tee top uniq unsparsify + altkv bar bootstrap cat check count-distinct count-similar cut decimate + filter fraction grep group-by group-like having-fields head histogram join + label least-frequent merge-fields most-frequent nest nothing put regularize + rename reorder repeat reshape sample sec2gmt sec2gmtdate seqgen shuffle sort + stats1 stats2 step tac tail tee top uniq unsparsify Functions for the filter and put verbs: + + - - * / // .+ .+ .- .- .* ./ .// % ** | ^ & ~ << >> bitcount == != =~