From dce2a185b70e9c4ea3878725368e52307d78ec9f Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 20 Feb 2017 21:18:03 -0500 Subject: [PATCH] doc neaten: faq --- doc/content-for-faq.html | 22 ++----- doc/cookbook.html | 100 ++++++++++++++++---------------- doc/data/delimiter-examples.txt | 13 ++--- doc/faq.html | 44 ++++++-------- 4 files changed, 78 insertions(+), 101 deletions(-) diff --git a/doc/content-for-faq.html b/doc/content-for-faq.html index e66aabd4a..162b8fa57 100644 --- a/doc/content-for-faq.html +++ b/doc/content-for-faq.html @@ -10,7 +10,8 @@ POKI_PUT_TOC_HERE

Try od -xcv and/or cat -e on your file to check for non-printable characters. -

If you’re using Miller version less than 5.0.0, when the +

If you’re using Miller version less than 5.0.0 (try +mlr --version on your system to find out), when the line-ending-autodetect feature was introduced, please see here. @@ -35,21 +36,6 @@ case: mlr --fs tab {remaining arguments ...}. POKI_INCLUDE_ESCAPED(data/delimiter-examples.txt)HERE - -

Error-output in certain string cases

- -
- -

mlr put '$y = string($x)' then put '$z = $y . $y' gives -(error) on numeric data such as x=123, while mlr put -'$z=string($x).string($x)' and mlr put '$y = string($x); $z = $y . -$y' do not. This is because in the first case y is computed and -stored as a string, then re-parsed as an integer, for which -string-concatenation is an invalid operator. In the second case, casts are done -independently; in the third case, both assignments are within the same -put statement, where type information is maintained for the duration -of all assignments in the put. -

How do I examine then-chaining?

@@ -141,6 +127,10 @@ numbers, you can use out-of-stream variables as follows: POKI_INCLUDE_AND_RUN_ESCAPED(data/dynamic-nr.sh)HERE +

Or, simply use mlr cat -n: + +POKI_RUN_COMMAND{{mlr filter '$x > 0.5' then cat -n data/small}}HERE +

Why am I not seeing all possible joins occur?

diff --git a/doc/cookbook.html b/doc/cookbook.html index 81507e9f3..08652aefb 100644 --- a/doc/cookbook.html +++ b/doc/cookbook.html @@ -1091,33 +1091,33 @@ $ mlr --ofmt '%.9lf' --opprint seqgen --start 1 --stop 28 then put ' ' then put '$seconds=systime()' then step -a delta -f seconds then cut -x -f seconds i o fcount seconds_delta 1 1 1 0 -2 2 3 0.000031948 +2 2 3 0.000035048 3 3 5 0.000013113 -4 5 9 0.000015020 -5 8 15 0.000020027 -6 13 25 0.000028849 -7 21 41 0.000043154 -8 34 67 0.000066996 -9 55 109 0.000104904 -10 89 177 0.000168085 -11 144 287 0.000270844 -12 233 465 0.000430107 -13 377 753 0.000833035 -14 610 1219 0.001605988 -15 987 1973 0.002301931 -16 1597 3193 0.003437996 -17 2584 5167 0.004857063 -18 4181 8361 0.007688999 -19 6765 13529 0.012132883 -20 10946 21891 0.019768000 -21 17711 35421 0.031412125 -22 28657 57313 0.051345825 -23 46368 92735 0.084591150 -24 75025 150049 0.129524946 -25 121393 242785 0.220007896 -26 196418 392835 0.369331121 -27 317811 635621 0.595546961 -28 514229 1028457 0.885719061 +4 5 9 0.000024796 +5 8 15 0.000020981 +6 13 25 0.000041008 +7 21 41 0.000055075 +8 34 67 0.000067949 +9 55 109 0.000109196 +10 89 177 0.000182867 +11 144 287 0.000307083 +12 233 465 0.000439882 +13 377 753 0.000730991 +14 610 1219 0.001173973 +15 987 1973 0.001893044 +16 1597 3193 0.003154993 +17 2584 5167 0.004925966 +18 4181 8361 0.007686138 +19 6765 13529 0.012122869 +20 10946 21891 0.019392014 +21 17711 35421 0.031095982 +22 28657 57313 0.050091982 +23 46368 92735 0.080941200 +24 75025 150049 0.130611897 +25 121393 242785 0.216569901 +26 196418 392835 0.340492010 +27 317811 635621 0.582877159 +28 514229 1028457 0.934934855

@@ -1149,33 +1149,33 @@ $ mlr --ofmt '%.9lf' --opprint seqgen --start 1 --stop 28 then put ' ' then put '$seconds=systime()' then step -a delta -f seconds then cut -x -f seconds i o fcount seconds_delta 1 1 1 0 -2 2 3 0.000035048 -3 3 3 0.000011921 -4 5 3 0.000010967 -5 8 3 0.000010967 -6 13 3 0.000010014 -7 21 3 0.000010014 +2 2 3 0.000036001 +3 3 3 0.000014067 +4 5 3 0.000011921 +5 8 3 0.000011921 +6 13 3 0.000011206 +7 21 3 0.000010967 8 34 3 0.000010967 -9 55 3 0.000009060 +9 55 3 0.000010967 10 89 3 0.000011921 -11 144 3 0.000010967 -12 233 3 0.000014067 -13 377 3 0.000010014 -14 610 3 0.000010014 -15 987 3 0.000010014 -16 1597 3 0.000010014 +11 144 3 0.000012159 +12 233 3 0.000015020 +13 377 3 0.000010967 +14 610 3 0.000011921 +15 987 3 0.000010967 +16 1597 3 0.000010967 17 2584 3 0.000010014 -18 4181 3 0.000010014 -19 6765 3 0.000009060 -20 10946 3 0.000010014 -21 17711 3 0.000009775 -22 28657 3 0.000010014 -23 46368 3 0.000012159 -24 75025 3 0.000010014 -25 121393 3 0.000010014 -26 196418 3 0.000008821 -27 317811 3 0.000010014 -28 514229 3 0.000010014 +18 4181 3 0.000010967 +19 6765 3 0.000010967 +20 10946 3 0.000011206 +21 17711 3 0.000010014 +22 28657 3 0.000010967 +23 46368 3 0.000012875 +24 75025 3 0.000010967 +25 121393 3 0.000011206 +26 196418 3 0.000009775 +27 317811 3 0.000011206 +28 514229 3 0.000010967

diff --git a/doc/data/delimiter-examples.txt b/doc/data/delimiter-examples.txt index 2a2f08fee..27d7c7233 100644 --- a/doc/data/delimiter-examples.txt +++ b/doc/data/delimiter-examples.txt @@ -9,18 +9,13 @@ KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_1;Weiß;White;Blanco;Valkoinen;Blanc;Bianco;Wit;Biały;Alb;Beyaz masterdata_colourcode_2;Schwarz;Black;Negro;Musta;Noir;Nero;Zwart;Czarny;Negru;Siyah -# Try (unsuccessfully) to extract a few fields: +# Extract a few fields: $ mlr --csv cut -f KEY,PL,RO data/colours.csv -(no output) - -# Use LF record separator (--rs lf) since the file doesn't have CR/LF line -# endings -- but still unsuccessfully: -$ mlr --csv --rs lf cut -f KEY,PL,RO data/colours.csv (only blank lines appear) # Use XTAB output format to get a sharper picture of where records/fields # are being split: -$ mlr --icsv --irs lf --oxtab cat data/colours.csv +$ mlr --icsv --oxtab cat data/colours.csv KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_1;Weiß;White;Blanco;Valkoinen;Blanc;Bianco;Wit;Biały;Alb;Beyaz KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_2;Schwarz;Black;Negro;Musta;Noir;Nero;Zwart;Czarny;Negru;Siyah @@ -30,7 +25,7 @@ KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_2;Schwarz;Black;Negro;Mu # subsequent line is being treated as a single field value. This is because # the default field separator is a comma but we have semicolons here. # Use XTAB again with different field separator (--fs semicolon): -$ mlr --icsv --irs lf --ifs semicolon --oxtab cat data/colours.csv + mlr --icsv --ifs semicolon --oxtab cat data/colours.csv KEY masterdata_colourcode_1 DE Weiß EN White @@ -56,7 +51,7 @@ RO Negru TR Siyah # Using the new field-separator, retry the cut: -$ mlr --csv --rs lf --fs semicolon cut -f KEY,PL,RO data/colours.csv + mlr --csv --fs semicolon cut -f KEY,PL,RO data/colours.csv KEY;PL;RO masterdata_colourcode_1;Biały;Alb masterdata_colourcode_2;Czarny;Negru diff --git a/doc/faq.html b/doc/faq.html index 6e6736a49..52cc18460 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -190,7 +190,6 @@ Miller commands were run with pretty-print-tabular output format. • No output at all
• Fields not selected
• Diagnosing delimiter specifications
-• Error-output in certain string cases
• How do I examine then-chaining?
• I assigned $9 and it’s not 9th
• Why doesn’t mlr cut put fields in the order I want?
@@ -210,7 +209,8 @@ Miller commands were run with pretty-print-tabular output format.

Try od -xcv and/or cat -e on your file to check for non-printable characters. -

If you’re using Miller version less than 5.0.0, when the +

If you’re using Miller version less than 5.0.0 (try +mlr --version on your system to find out), when the line-ending-autodetect feature was introduced, please see here. @@ -247,18 +247,13 @@ KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_1;Weiß;White;Blanco;Valkoinen;Blanc;Bianco;Wit;Biały;Alb;Beyaz masterdata_colourcode_2;Schwarz;Black;Negro;Musta;Noir;Nero;Zwart;Czarny;Negru;Siyah -# Try (unsuccessfully) to extract a few fields: +# Extract a few fields: $ mlr --csv cut -f KEY,PL,RO data/colours.csv -(no output) - -# Use LF record separator (--rs lf) since the file doesn't have CR/LF line -# endings -- but still unsuccessfully: -$ mlr --csv --rs lf cut -f KEY,PL,RO data/colours.csv (only blank lines appear) # Use XTAB output format to get a sharper picture of where records/fields # are being split: -$ mlr --icsv --irs lf --oxtab cat data/colours.csv +$ mlr --icsv --oxtab cat data/colours.csv KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_1;Weiß;White;Blanco;Valkoinen;Blanc;Bianco;Wit;Biały;Alb;Beyaz KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_2;Schwarz;Black;Negro;Musta;Noir;Nero;Zwart;Czarny;Negru;Siyah @@ -268,7 +263,7 @@ KEY;DE;EN;ES;FI;FR;IT;NL;PL;RO;TR masterdata_colourcode_2;Schwarz;Black;Negro;Mu # subsequent line is being treated as a single field value. This is because # the default field separator is a comma but we have semicolons here. # Use XTAB again with different field separator (--fs semicolon): -$ mlr --icsv --irs lf --ifs semicolon --oxtab cat data/colours.csv + mlr --icsv --ifs semicolon --oxtab cat data/colours.csv KEY masterdata_colourcode_1 DE Weiß EN White @@ -294,7 +289,7 @@ RO Negru TR Siyah # Using the new field-separator, retry the cut: -$ mlr --csv --rs lf --fs semicolon cut -f KEY,PL,RO data/colours.csv + mlr --csv --fs semicolon cut -f KEY,PL,RO data/colours.csv KEY;PL;RO masterdata_colourcode_1;Biały;Alb masterdata_colourcode_2;Czarny;Negru @@ -302,21 +297,6 @@ masterdata_colourcode_2;Czarny;Negru

- -

Error-output in certain string cases

- -
- -

mlr put '$y = string($x)' then put '$z = $y . $y' gives -(error) on numeric data such as x=123, while mlr put -'$z=string($x).string($x)' and mlr put '$y = string($x); $z = $y . -$y' do not. This is because in the first case y is computed and -stored as a string, then re-parsed as an integer, for which -string-concatenation is an invalid operator. In the second case, casts are done -independently; in the third case, both assignments are within the same -put statement, where type information is maintained for the duration -of all assignments in the put. -

How do I examine then-chaining?

@@ -582,6 +562,18 @@ wye pan 5 0.5732889198020006 0.8636244699032729 5 2

+

Or, simply use mlr cat -n: + +

+

+
+$ mlr filter '$x > 0.5' then cat -n data/small
+n=1,a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
+n=2,a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
+
+
+

+

Why am I not seeing all possible joins occur?