mirror of
https://github.com/johnkerl/miller.git
synced 2026-08-01 20:12:19 +00:00
doc neaten: file formats
This commit is contained in:
parent
dea815d1b4
commit
172dfd32b7
11 changed files with 99 additions and 96 deletions
|
|
@ -743,9 +743,9 @@ static void main_usage_format_conversion_keystroke_saver_options(FILE* o, char*
|
|||
fprintf(o, " --j2c --j2t --j2d --j2n --j2x --j2p --j2m\n");
|
||||
fprintf(o, " --x2c --x2t --x2d --x2n --x2j --x2p --x2m\n");
|
||||
fprintf(o, " --p2c --p2t --p2d --p2n --p2j --p2x --p2m\n");
|
||||
fprintf(o, "The letters c t d n j x p m refer to formats CSV with LF, TSV with LF, DKVP,\n");
|
||||
fprintf(o, "NIDX, JSON, XTAB, PPRINT, and markdown, respectively. Note that markdown format\n");
|
||||
fprintf(o, "is available for output only.\n");
|
||||
fprintf(o, "The letters c t d n j x p m refer to formats CSV, TSV, DKVP, NIDX, JSON, XTAB,\n");
|
||||
fprintf(o, "PPRINT, and markdown, respectively. Note that markdown format is available for\n");
|
||||
fprintf(o, "output only.\n");
|
||||
}
|
||||
|
||||
static void main_usage_compressed_data_options(FILE* o, char* argv0) {
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ purple square 0 91 72.3735 8.2430
|
|||
</div>
|
||||
<p/>
|
||||
|
||||
<p/><boldmaroon> <tt>mlr head</tt> and <tt>mlr tail</tt> count records. The CSV
|
||||
<p/><boldmaroon> <tt>mlr head</tt> and <tt>mlr tail</tt> count records rather than lines. The CSV
|
||||
header is included either way:</boldmaroon>
|
||||
|
||||
<p/>
|
||||
|
|
@ -445,6 +445,9 @@ $ mlr --icsv --ojson put '$ratio = $quantity/$rate; $shape = toupper($shape)' ex
|
|||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
||||
<p/><boldmaroon> JSON output with vertical-formatting flags:</boldmaroon>
|
||||
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
<pre>
|
||||
|
|
@ -472,9 +475,10 @@ $ mlr --icsv --ojson --jvstack --jlistwrap tail -n 2 example.csv
|
|||
<p/>
|
||||
|
||||
<p/><boldmaroon> Use <tt>then</tt> to pipe commands together. Also, the
|
||||
<tt>-g</tt> option for many Miller commands is for group-by: here,
|
||||
<tt>head -n 1 -g shape</tt> outputs the first record for each distinct
|
||||
value of the <tt>shape</tt> field.</boldmaroon>
|
||||
<tt>-g</tt> option for many Miller commands is for group-by: here, <tt>head -n
|
||||
1 -g shape</tt> outputs the first record for each distinct value of the
|
||||
<tt>shape</tt> field. This means we’re finding the record with highest
|
||||
<tt>index</tt> field for each distinct <tt>shape</tt> field:</boldmaroon>
|
||||
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ POKI_RUN_COMMAND{{mlr --csv cat example.csv}}HERE
|
|||
|
||||
POKI_RUN_COMMAND{{mlr --icsv --opprint cat example.csv}}HERE
|
||||
|
||||
<p/><boldmaroon> <tt>mlr head</tt> and <tt>mlr tail</tt> count records. The CSV
|
||||
<p/><boldmaroon> <tt>mlr head</tt> and <tt>mlr tail</tt> count records rather than lines. The CSV
|
||||
header is included either way:</boldmaroon>
|
||||
|
||||
POKI_RUN_COMMAND{{mlr --csv head -n 4 example.csv}}HERE
|
||||
|
|
@ -55,12 +55,16 @@ POKI_RUN_COMMAND{{mlr --icsv --opprint put '$ratio = $quantity / $rate; $color_s
|
|||
<p/><boldmaroon> JSON output:</boldmaroon>
|
||||
|
||||
POKI_RUN_COMMAND{{mlr --icsv --ojson put '$ratio = $quantity/$rate; $shape = toupper($shape)' example.csv}}HERE
|
||||
|
||||
<p/><boldmaroon> JSON output with vertical-formatting flags:</boldmaroon>
|
||||
|
||||
POKI_RUN_COMMAND{{mlr --icsv --ojson --jvstack --jlistwrap tail -n 2 example.csv}}HERE
|
||||
|
||||
<p/><boldmaroon> Use <tt>then</tt> to pipe commands together. Also, the
|
||||
<tt>-g</tt> option for many Miller commands is for group-by: here,
|
||||
<tt>head -n 1 -g shape</tt> outputs the first record for each distinct
|
||||
value of the <tt>shape</tt> field.</boldmaroon>
|
||||
<tt>-g</tt> option for many Miller commands is for group-by: here, <tt>head -n
|
||||
1 -g shape</tt> outputs the first record for each distinct value of the
|
||||
<tt>shape</tt> field. This means we’re finding the record with highest
|
||||
<tt>index</tt> field for each distinct <tt>shape</tt> field:</boldmaroon>
|
||||
|
||||
POKI_RUN_COMMAND{{mlr --icsv --opprint sort -f shape -nr index then head -n 1 -g shape example.csv}}HERE
|
||||
|
||||
|
|
|
|||
|
|
@ -56,15 +56,12 @@ of platform.
|
|||
|
||||
<li/>CSV supports <a href="https://tools.ietf.org/html/rfc4180">
|
||||
RFC-4180</a>)-style double-quoting, including the ability to have commas and/or
|
||||
CR-LF line-endings contained within an input field; CSV-lite does not.
|
||||
|
||||
<li/>Default record separator for CSV is CR-LF; default record separator for
|
||||
CSV-lite is LF.
|
||||
LF/CRLF line-endings contained within an input field; CSV-lite does not.
|
||||
|
||||
<li/>CSV does not allow heterogeneous data; CSV-lite does (see also <a
|
||||
href="record-heterogeneity.html">here</a>).
|
||||
|
||||
<li/>The CSV-lite input-reading code is more efficient than the CSV
|
||||
<li/>The CSV-lite input-reading code is fractionally more efficient than the CSV
|
||||
input-reader.
|
||||
|
||||
</ul>
|
||||
|
|
@ -220,9 +217,9 @@ truly powerful, JSON-specific tool.
|
|||
|
||||
<h2>JSON non-streaming</h2>
|
||||
|
||||
<p/>The JSON parser does not return until all input is parsed: in particular
|
||||
this means that, unlike for other file formats, Miller does not (at present)
|
||||
handle JSON files in <tt>tail -f</tt> contexts.
|
||||
<p/>The JSON parser Miller uses does not return until all input is parsed: in
|
||||
particular this means that, unlike for other file formats, Miller does not (at
|
||||
present) handle JSON files in <tt>tail -f</tt> contexts.
|
||||
|
||||
</div>
|
||||
<h1>PPRINT: Pretty-printed tabular</h1>
|
||||
|
|
@ -302,7 +299,7 @@ POKI_RUN_COMMAND{{mlr --usage-format-conversion-keystroke-saver-options}}HERE
|
|||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_autodetect_line_endings');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_autodetect_line_endings" style="display: block">
|
||||
|
||||
<p/> Default line endings (<tt>--irs</tt> and <tt>--ors</tt>) are <tt>auto</tt>
|
||||
<p/> Default line endings (<tt>--irs</tt> and <tt>--ors</tt>) are <tt>'auto'</tt>
|
||||
which means <boldmaroon>autodetect from the input file format</boldmaroon>, as
|
||||
long as the input file(s) have lines ending in either LF (also known as
|
||||
linefeed, <tt>'\n'</tt>, <tt>0x0a</tt>, Unix-style) or CRLF (also known as
|
||||
|
|
|
|||
|
|
@ -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.000030994
|
||||
3 3 5 0.000012875
|
||||
2 2 3 0.000034094
|
||||
3 3 5 0.000011921
|
||||
4 5 9 0.000015020
|
||||
5 8 15 0.000020027
|
||||
6 13 25 0.000029087
|
||||
7 21 41 0.000042915
|
||||
8 34 67 0.000066996
|
||||
9 55 109 0.000104904
|
||||
10 89 177 0.000168085
|
||||
11 144 287 0.000272036
|
||||
12 233 465 0.000429869
|
||||
13 377 753 0.000686169
|
||||
14 610 1219 0.001107931
|
||||
15 987 1973 0.001784086
|
||||
16 1597 3193 0.002952814
|
||||
17 2584 5167 0.004665136
|
||||
18 4181 8361 0.007502079
|
||||
19 6765 13529 0.012058973
|
||||
20 10946 21891 0.019434929
|
||||
21 17711 35421 0.031375885
|
||||
22 28657 57313 0.049787998
|
||||
23 46368 92735 0.080844164
|
||||
24 75025 150049 0.129994869
|
||||
25 121393 242785 0.209208965
|
||||
26 196418 392835 0.344423056
|
||||
27 317811 635621 0.583369017
|
||||
28 514229 1028457 0.946258068
|
||||
5 8 15 0.000020981
|
||||
6 13 25 0.000030041
|
||||
7 21 41 0.000044107
|
||||
8 34 67 0.000068903
|
||||
9 55 109 0.000108004
|
||||
10 89 177 0.000171900
|
||||
11 144 287 0.000279188
|
||||
12 233 465 0.000441790
|
||||
13 377 753 0.000728130
|
||||
14 610 1219 0.001293898
|
||||
15 987 1973 0.001834154
|
||||
16 1597 3193 0.004330873
|
||||
17 2584 5167 0.006086111
|
||||
18 4181 8361 0.008031845
|
||||
19 6765 13529 0.012267113
|
||||
20 10946 21891 0.020168066
|
||||
21 17711 35421 0.031072855
|
||||
22 28657 57313 0.055731058
|
||||
23 46368 92735 0.080446005
|
||||
24 75025 150049 0.130995035
|
||||
25 121393 242785 0.207859993
|
||||
26 196418 392835 0.338934898
|
||||
27 317811 635621 0.546113968
|
||||
28 514229 1028457 0.924782991
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
@ -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.000034809
|
||||
3 3 3 0.000013113
|
||||
2 2 3 0.000039101
|
||||
3 3 3 0.000014067
|
||||
4 5 3 0.000010967
|
||||
5 8 3 0.000010967
|
||||
6 13 3 0.000010967
|
||||
7 21 3 0.000010014
|
||||
8 34 3 0.000010014
|
||||
9 55 3 0.000010967
|
||||
10 89 3 0.000012159
|
||||
11 144 3 0.000010014
|
||||
12 233 3 0.000013828
|
||||
13 377 3 0.000011206
|
||||
14 610 3 0.000010014
|
||||
15 987 3 0.000009775
|
||||
16 1597 3 0.000010014
|
||||
17 2584 3 0.000011206
|
||||
18 4181 3 0.000009775
|
||||
19 6765 3 0.000010014
|
||||
20 10946 3 0.000010014
|
||||
7 21 3 0.000010967
|
||||
8 34 3 0.000010967
|
||||
9 55 3 0.000011206
|
||||
10 89 3 0.000011921
|
||||
11 144 3 0.000010967
|
||||
12 233 3 0.000015974
|
||||
13 377 3 0.000011921
|
||||
14 610 3 0.000011206
|
||||
15 987 3 0.000011921
|
||||
16 1597 3 0.000010967
|
||||
17 2584 3 0.000010967
|
||||
18 4181 3 0.000010967
|
||||
19 6765 3 0.000012159
|
||||
20 10946 3 0.000010967
|
||||
21 17711 3 0.000010014
|
||||
22 28657 3 0.000010014
|
||||
23 46368 3 0.000012159
|
||||
24 75025 3 0.000010014
|
||||
22 28657 3 0.000010967
|
||||
23 46368 3 0.000012875
|
||||
24 75025 3 0.000012159
|
||||
25 121393 3 0.000010967
|
||||
26 196418 3 0.000010014
|
||||
27 317811 3 0.000010014
|
||||
28 514229 3 0.000009775
|
||||
26 196418 3 0.000010967
|
||||
27 317811 3 0.000010967
|
||||
28 514229 3 0.000010967
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
|
|||
|
|
@ -567,11 +567,11 @@ begin {
|
|||
@iwidth = 100;
|
||||
@maxits = 100;
|
||||
@levelstep = 5;
|
||||
@chars = "@X*o-.";
|
||||
@chars = "@X*o-."; # Palette of characters to print to the screen.
|
||||
@verbose = false;
|
||||
@do_julia = false;
|
||||
@jr = 0.0;
|
||||
@ji = 0.0;
|
||||
@jr = 0.0; # Real part of Julia point, if any
|
||||
@ji = 0.0; # Imaginary part of Julia point, if any
|
||||
}
|
||||
|
||||
# Here, we can override defaults from an input file (if any). In Miller's
|
||||
|
|
@ -614,7 +614,8 @@ end {
|
|||
}
|
||||
}
|
||||
|
||||
# Function to approximate membership in the Mandelbrot set for a given point in the
|
||||
# This is a function to approximate membership in the Mandelbrot set (or Julia
|
||||
# set for a given Julia point if do_julia == true) for a given point in the
|
||||
# complex plane.
|
||||
func get_point_plot(pr, pi, maxits, do_julia, jr, ji) {
|
||||
num zr = 0.0;
|
||||
|
|
|
|||
|
|
@ -326,15 +326,12 @@ of platform.
|
|||
|
||||
<li/>CSV supports <a href="https://tools.ietf.org/html/rfc4180">
|
||||
RFC-4180</a>)-style double-quoting, including the ability to have commas and/or
|
||||
CR-LF line-endings contained within an input field; CSV-lite does not.
|
||||
|
||||
<li/>Default record separator for CSV is CR-LF; default record separator for
|
||||
CSV-lite is LF.
|
||||
LF/CRLF line-endings contained within an input field; CSV-lite does not.
|
||||
|
||||
<li/>CSV does not allow heterogeneous data; CSV-lite does (see also <a
|
||||
href="record-heterogeneity.html">here</a>).
|
||||
|
||||
<li/>The CSV-lite input-reading code is more efficient than the CSV
|
||||
<li/>The CSV-lite input-reading code is fractionally more efficient than the CSV
|
||||
input-reader.
|
||||
|
||||
</ul>
|
||||
|
|
@ -683,9 +680,9 @@ truly powerful, JSON-specific tool.
|
|||
|
||||
<a id="JSON_non-streaming"/><h2>JSON non-streaming</h2>
|
||||
|
||||
<p/>The JSON parser does not return until all input is parsed: in particular
|
||||
this means that, unlike for other file formats, Miller does not (at present)
|
||||
handle JSON files in <tt>tail -f</tt> contexts.
|
||||
<p/>The JSON parser Miller uses does not return until all input is parsed: in
|
||||
particular this means that, unlike for other file formats, Miller does not (at
|
||||
present) handle JSON files in <tt>tail -f</tt> contexts.
|
||||
|
||||
</div>
|
||||
<a id="PPRINT:_Pretty-printed_tabular"/><h1>PPRINT: Pretty-printed tabular</h1>
|
||||
|
|
@ -866,9 +863,9 @@ As keystroke-savers for format-conversion you may use the following:
|
|||
--j2c --j2t --j2d --j2n --j2x --j2p --j2m
|
||||
--x2c --x2t --x2d --x2n --x2j --x2p --x2m
|
||||
--p2c --p2t --p2d --p2n --p2j --p2x --p2m
|
||||
The letters c t d n j x p m refer to formats CSV with LF, TSV with LF, DKVP,
|
||||
NIDX, JSON, XTAB, PPRINT, and markdown, respectively. Note that markdown format
|
||||
is available for output only.
|
||||
The letters c t d n j x p m refer to formats CSV, TSV, DKVP, NIDX, JSON, XTAB,
|
||||
PPRINT, and markdown, respectively. Note that markdown format is available for
|
||||
output only.
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
@ -880,7 +877,7 @@ is available for output only.
|
|||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_autodetect_line_endings');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_autodetect_line_endings" style="display: block">
|
||||
|
||||
<p/> Default line endings (<tt>--irs</tt> and <tt>--ors</tt>) are <tt>auto</tt>
|
||||
<p/> Default line endings (<tt>--irs</tt> and <tt>--ors</tt>) are <tt>'auto'</tt>
|
||||
which means <boldmaroon>autodetect from the input file format</boldmaroon>, as
|
||||
long as the input file(s) have lines ending in either LF (also known as
|
||||
linefeed, <tt>'\n'</tt>, <tt>0x0a</tt>, Unix-style) or CRLF (also known as
|
||||
|
|
|
|||
|
|
@ -389,9 +389,9 @@ OPTIONS
|
|||
--j2c --j2t --j2d --j2n --j2x --j2p --j2m
|
||||
--x2c --x2t --x2d --x2n --x2j --x2p --x2m
|
||||
--p2c --p2t --p2d --p2n --p2j --p2x --p2m
|
||||
The letters c t d n j x p m refer to formats CSV with LF, TSV with LF, DKVP,
|
||||
NIDX, JSON, XTAB, PPRINT, and markdown, respectively. Note that markdown format
|
||||
is available for output only.
|
||||
The letters c t d n j x p m refer to formats CSV, TSV, DKVP, NIDX, JSON, XTAB,
|
||||
PPRINT, and markdown, respectively. Note that markdown format is available for
|
||||
output only.
|
||||
|
||||
COMPRESSED I/O
|
||||
--prepipe {command} This allows Miller to handle compressed inputs. You can do
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ OPTIONS
|
|||
--j2c --j2t --j2d --j2n --j2x --j2p --j2m
|
||||
--x2c --x2t --x2d --x2n --x2j --x2p --x2m
|
||||
--p2c --p2t --p2d --p2n --p2j --p2x --p2m
|
||||
The letters c t d n j x p m refer to formats CSV with LF, TSV with LF, DKVP,
|
||||
NIDX, JSON, XTAB, PPRINT, and markdown, respectively. Note that markdown format
|
||||
is available for output only.
|
||||
The letters c t d n j x p m refer to formats CSV, TSV, DKVP, NIDX, JSON, XTAB,
|
||||
PPRINT, and markdown, respectively. Note that markdown format is available for
|
||||
output only.
|
||||
|
||||
COMPRESSED I/O
|
||||
--prepipe {command} This allows Miller to handle compressed inputs. You can do
|
||||
|
|
|
|||
|
|
@ -257,9 +257,9 @@ As keystroke-savers for format-conversion you may use the following:
|
|||
--j2c --j2t --j2d --j2n --j2x --j2p --j2m
|
||||
--x2c --x2t --x2d --x2n --x2j --x2p --x2m
|
||||
--p2c --p2t --p2d --p2n --p2j --p2x --p2m
|
||||
The letters c t d n j x p m refer to formats CSV with LF, TSV with LF, DKVP,
|
||||
NIDX, JSON, XTAB, PPRINT, and markdown, respectively. Note that markdown format
|
||||
is available for output only.
|
||||
The letters c t d n j x p m refer to formats CSV, TSV, DKVP, NIDX, JSON, XTAB,
|
||||
PPRINT, and markdown, respectively. Note that markdown format is available for
|
||||
output only.
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
|
|
|
|||
|
|
@ -499,9 +499,9 @@ As keystroke-savers for format-conversion you may use the following:
|
|||
--j2c --j2t --j2d --j2n --j2x --j2p --j2m
|
||||
--x2c --x2t --x2d --x2n --x2j --x2p --x2m
|
||||
--p2c --p2t --p2d --p2n --p2j --p2x --p2m
|
||||
The letters c t d n j x p m refer to formats CSV with LF, TSV with LF, DKVP,
|
||||
NIDX, JSON, XTAB, PPRINT, and markdown, respectively. Note that markdown format
|
||||
is available for output only.
|
||||
The letters c t d n j x p m refer to formats CSV, TSV, DKVP, NIDX, JSON, XTAB,
|
||||
PPRINT, and markdown, respectively. Note that markdown format is available for
|
||||
output only.
|
||||
|
||||
Compressed-data options:
|
||||
--prepipe {command} This allows Miller to handle compressed inputs. You can do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue