mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-21 02:23:20 +00:00
more section-visibility JS toggles
This commit is contained in:
parent
5147322e6e
commit
8ef4cf1046
5 changed files with 180 additions and 45 deletions
|
|
@ -335,6 +335,7 @@ DOC:
|
|||
* 10-min
|
||||
* inverse-transform-sampling example at cookbook.
|
||||
* mlr -F and -K. Note -l -L -f -F -k -K.
|
||||
* section toggles
|
||||
* go/d/rust cmps @ getline
|
||||
* ruby/python cmps @ mand
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,13 @@ Miller commands were run with pretty-print-tabular output format.
|
|||
</div>
|
||||
<p/>
|
||||
|
||||
<p/>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="expand_all();" href="javascript:;">Expand all sections</button>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="collapse_all();" href="javascript:;">Collapse all sections</button>
|
||||
|
||||
<a id="CSV-file_examples"/><h1>CSV-file examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_csv_file_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_csv_file_examples" style="display: block">
|
||||
|
||||
<p/><boldmaroon> Sample CSV data file: </boldmaroon>
|
||||
|
||||
|
|
@ -524,7 +530,10 @@ square purple 1 72.373500 72.373500 72.373500
|
|||
</div>
|
||||
<p/>
|
||||
|
||||
</div>
|
||||
<a id="Choices_for_printing_to_files"/><h1>Choices for printing to files</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_printing_to_files');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_printing_to_files" style="display: block">
|
||||
|
||||
<p/>Often we want to print output <boldmaroon>to the screen</boldmaroon>. Miller does this by default, as we’ve
|
||||
seen in the previous examples.
|
||||
|
|
@ -652,7 +661,10 @@ purple,triangle,0,65,80.1405,5.8240
|
|||
<p/>
|
||||
</td></tr></table>
|
||||
|
||||
</div>
|
||||
<a id="Other-format_examples"/><h1>Other-format examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_other_format_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_other_format_examples" style="display: block">
|
||||
|
||||
<p/>What’s a CSV file, really? It’s an array of rows, or
|
||||
<i>records</i>, each being a list of key-value pairs, or <i>fields</i>: for CSV
|
||||
|
|
@ -707,7 +719,10 @@ other format input data.</boldmaroon> And you can read from one format, do any
|
|||
record-processing, and output to the same format as the input, or to a
|
||||
different output format.
|
||||
|
||||
</div>
|
||||
<a id="SQL-output_examples"/><h1>SQL-output examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_sql_output_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_sql_output_examples" style="display: block">
|
||||
|
||||
<p/>I like to produce SQL-query output with header-column and tab delimiter:
|
||||
this is CSV but with a tab instead of a comma, also known as TSV. Then I
|
||||
|
|
@ -820,7 +835,10 @@ standard 10009872 108
|
|||
<p/>Again, all the examples in the CSV section apply here — just change the input-format
|
||||
flags.
|
||||
|
||||
</div>
|
||||
<a id="Log-processing_examples"/><h1>Log-processing examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_log_processing_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_log_processing_examples" style="display: block">
|
||||
|
||||
<p/>Another of my favorite use-cases for Miller is doing ad-hoc processing of
|
||||
log-file data. Here’s where DKVP format really shines: one, since the
|
||||
|
|
@ -1038,11 +1056,16 @@ time batch_size num_filtered
|
|||
</div>
|
||||
<p/>
|
||||
|
||||
</div>
|
||||
<a id="More"/><h1>More</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_more');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_more" style="display: block">
|
||||
|
||||
<p/>Please see the <a href="reference.html">reference</a> for complete
|
||||
information, as well as the <a href="faq.html">FAQ</a> and the <a
|
||||
href="cookbook.html">cookbook</a> for more tips.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
POKI_PUT_TOC_HERE
|
||||
|
||||
<p/>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="expand_all();" href="javascript:;">Expand all sections</button>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="collapse_all();" href="javascript:;">Collapse all sections</button>
|
||||
|
||||
<h1>CSV-file examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_csv_file_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_csv_file_examples" style="display: block">
|
||||
|
||||
<p/><boldmaroon> Sample CSV data file: </boldmaroon>
|
||||
|
||||
|
|
@ -66,7 +72,10 @@ POKI_RUN_COMMAND{{mlr --icsv --oxtab --from example.csv stats1 -a p0,p10,p25,p50
|
|||
POKI_RUN_COMMAND{{mlr --icsv --opprint --from example.csv stats1 -a count,min,mean,max -f quantity -g shape}}HERE
|
||||
POKI_RUN_COMMAND{{mlr --icsv --opprint --from example.csv stats1 -a count,min,mean,max -f quantity -g shape,color}}HERE
|
||||
|
||||
</div>
|
||||
<h1>Choices for printing to files</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_printing_to_files');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_printing_to_files" style="display: block">
|
||||
|
||||
<p/>Often we want to print output <boldmaroon>to the screen</boldmaroon>. Miller does this by default, as we’ve
|
||||
seen in the previous examples.
|
||||
|
|
@ -157,7 +166,10 @@ POKI_RUN_COMMAND{{cat square.csv}}HERE
|
|||
POKI_RUN_COMMAND{{cat triangle.csv}}HERE
|
||||
</td></tr></table>
|
||||
|
||||
</div>
|
||||
<h1>Other-format examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_other_format_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_other_format_examples" style="display: block">
|
||||
|
||||
<p/>What’s a CSV file, really? It’s an array of rows, or
|
||||
<i>records</i>, each being a list of key-value pairs, or <i>fields</i>: for CSV
|
||||
|
|
@ -212,7 +224,10 @@ other format input data.</boldmaroon> And you can read from one format, do any
|
|||
record-processing, and output to the same format as the input, or to a
|
||||
different output format.
|
||||
|
||||
</div>
|
||||
<h1>SQL-output examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_sql_output_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_sql_output_examples" style="display: block">
|
||||
|
||||
<p/>I like to produce SQL-query output with header-column and tab delimiter:
|
||||
this is CSV but with a tab instead of a comma, also known as TSV. Then I
|
||||
|
|
@ -325,7 +340,10 @@ standard 10009872 108
|
|||
<p/>Again, all the examples in the CSV section apply here — just change the input-format
|
||||
flags.
|
||||
|
||||
</div>
|
||||
<h1>Log-processing examples</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_log_processing_examples');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_log_processing_examples" style="display: block">
|
||||
|
||||
<p/>Another of my favorite use-cases for Miller is doing ad-hoc processing of
|
||||
log-file data. Here’s where DKVP format really shines: one, since the
|
||||
|
|
@ -359,8 +377,13 @@ POKI_INCLUDE_AND_RUN_ESCAPED(10-2.sh)HERE
|
|||
POKI_RUN_COMMAND{{mlr --opprint group-like log.txt}}HERE
|
||||
POKI_RUN_COMMAND{{mlr --opprint group-like then sec2gmt time log.txt}}HERE
|
||||
|
||||
</div>
|
||||
<h1>More</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_more');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_more" style="display: block">
|
||||
|
||||
<p/>Please see the <a href="reference.html">reference</a> for complete
|
||||
information, as well as the <a href="faq.html">FAQ</a> and the <a
|
||||
href="cookbook.html">cookbook</a> for more tips.
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
POKI_PUT_TOC_HERE
|
||||
|
||||
<p/>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="expand_all();" href="javascript:;">Expand all sections</button>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="collapse_all();" href="javascript:;">Collapse all sections</button>
|
||||
|
||||
<p/><b>Disclaimer:</b> This page is about how to do some corner-case things in
|
||||
ways you mightn’t have thought of. For an intro, please also see
|
||||
<a href="10-min.html">Miller in 10 minutes</a>.
|
||||
|
||||
<!-- ================================================================ -->
|
||||
<h1>Parsing log-file output</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_parsing_log_file_output');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_parsing_log_file_output" style="display: block">
|
||||
|
||||
<p/>This, of course, depends highly on what’s in your log files. But, as
|
||||
an example, suppose you have log-file lines such as
|
||||
|
|
@ -17,7 +23,10 @@ I prefer to pre-filter with <tt>grep</tt> and/or <tt>sed</tt> to extract the str
|
|||
POKI_CARDIFY(grep 'various sorts' *.log | sed 's/.*} //' | mlr --fs space --repifs --oxtab stats1 -a min,p10,p50,p90,max -f time -g status)HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Rectangularizing data</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_rectangularizing_data');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_rectangularizing_data" style="display: block">
|
||||
|
||||
<p/>Suppose you have a method (in whatever language) which is printing things of the form
|
||||
|
||||
|
|
@ -48,7 +57,10 @@ output when you see the inner IDs.
|
|||
POKI_INCLUDE_AND_RUN_ESCAPED(data/rect.sh)HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Bulk rename of field names</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_bulk_rename');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_bulk_rename" style="display: block">
|
||||
|
||||
POKI_RUN_COMMAND{{cat data/spaces.csv}}HERE
|
||||
POKI_RUN_COMMAND{{mlr --csv rename -r -g ' ,_' data/spaces.csv}}HERE
|
||||
|
|
@ -61,7 +73,10 @@ POKI_RUN_COMMAND{{cat data/bulk-rename-for-loop.mlr}}HERE
|
|||
POKI_RUN_COMMAND{{mlr --icsv --opprint put -f data/bulk-rename-for-loop.mlr data/spaces.csv}}HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Headerless CSV on input or output</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_headerless_csv');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_headerless_csv" style="display: block">
|
||||
|
||||
<p/>Sometimes we get CSV files which lack a header. For example:
|
||||
|
||||
|
|
@ -85,7 +100,10 @@ POKI_RUN_COMMAND{{head -5 data/colored-shapes.dkvp | mlr --ocsv cat}}HERE
|
|||
POKI_RUN_COMMAND{{head -5 data/colored-shapes.dkvp | mlr --ocsv --headerless-csv-output cat}}HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Regularizing ragged CSV</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_rectangularizing_ragged_csv');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_rectangularizing_ragged_csv" style="display: block">
|
||||
|
||||
<p/>Miller handles compliant CSV: in particular, it’s an error if the
|
||||
number of data fields in a given data line don’t match the number of
|
||||
|
|
@ -102,7 +120,10 @@ or, more simply,
|
|||
POKI_INCLUDE_AND_RUN_ESCAPED(data/ragged-csv-2.sh)HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Program timing</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_program_timing');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_program_timing" style="display: block">
|
||||
|
||||
This admittedly artificial example demonstrates using Miller time and stats
|
||||
functions to introspectly acquire some information about Miller’s own
|
||||
|
|
@ -112,7 +133,10 @@ timestamps.
|
|||
POKI_INCLUDE_ESCAPED(data/timing-example.txt)HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Memoization with out-of-stream variables</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_memoization_with_oosvars');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_memoization_with_oosvars" style="display: block">
|
||||
|
||||
<p/> The recursive function for the Fibonacci sequence is famous for its computational complexity.
|
||||
Namely, using
|
||||
|
|
@ -131,7 +155,10 @@ of previous computations:
|
|||
POKI_INCLUDE_AND_RUN_ESCAPED(data/fibo-cached.sh)HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Finding missing dates</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_finding_missing_dates');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_finding_missing_dates" style="display: block">
|
||||
|
||||
<p/>Suppose you have some date-stamped data which may (or may not) be missing entries for one or more dates:
|
||||
|
||||
|
|
@ -153,7 +180,10 @@ POKI_RUN_COMMAND{{mlr cat -n then filter '$n >= 770 && $n <= 780' data/miss-date
|
|||
POKI_RUN_COMMAND{{mlr cat -n then filter '$n >= 1115 && $n <= 1125' data/miss-date.csv}}HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Generating random variables</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_generating_random_variables');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_generating_random_variables" style="display: block">
|
||||
|
||||
<p/>Here can chain together a few simple building blocks:
|
||||
|
||||
|
|
@ -177,7 +207,10 @@ The output is as follows:
|
|||
POKI_RUN_COMMAND{{sh expo-sample.sh}}HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Two-pass algorithms</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_two_pass_algorithms');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_two_pass_algorithms" style="display: block">
|
||||
|
||||
<p/>Miller is a streaming record processor; commands are performed once per
|
||||
record. This makes Miller particularly suitable for single-pass algorithms,
|
||||
|
|
@ -220,7 +253,10 @@ POKI_RUN_COMMAND{{cat data/maxrows.mlr}}HERE
|
|||
POKI_RUN_COMMAND{{mlr --itsv --opprint put -q -f data/maxrows.mlr data/maxrows.tsv}}HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Filtering paragraphs of text</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_filtering_paragraphs_of_text');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_filtering_paragraphs_of_text" style="display: block">
|
||||
|
||||
<p/>The idea is to use a record separator which is a pair of newlines. Then, if
|
||||
you want each paragraph to be a record with a single value, use a
|
||||
|
|
@ -235,12 +271,18 @@ POKI_RUN_COMMAND{{mlr --from paragraphs.txt --nidx --rs '\n\n' --fs '\001' filte
|
|||
POKI_RUN_COMMAND{{mlr --from paragraphs.txt --nidx --rs '\n\n' --fs '\n' cut -f 1,3}}HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Doing arithmetic on fields with currency symbols</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_doing_arithmetic_with_currency_symbols');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_doing_arithmetic_with_currency_symbols" style="display: block">
|
||||
|
||||
POKI_INCLUDE_ESCAPED(data/dollar-sign.txt)HERE
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<h1>Using out-of-stream variables</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_using_oosvars');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_using_oosvars" style="display: block">
|
||||
|
||||
<p/> One of Miller’s strengths is its compact notation: for example, given input of the form
|
||||
|
||||
|
|
@ -322,3 +364,5 @@ POKI_RUN_COMMAND{{mlr --opprint put '$x_delta = is_present(@last[$a]) ? $x - @la
|
|||
POKI_INCLUDE_AND_RUN_ESCAPED(verb-example-ewma.sh)HERE
|
||||
|
||||
POKI_INCLUDE_AND_RUN_ESCAPED(oosvar-example-ewma.sh)HERE
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -211,12 +211,18 @@ Miller commands were run with pretty-print-tabular output format.
|
|||
</div>
|
||||
<p/>
|
||||
|
||||
<p/>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="expand_all();" href="javascript:;">Expand all sections</button>
|
||||
<button style="font-weight:bold;color:maroon;border:0" onclick="collapse_all();" href="javascript:;">Collapse all sections</button>
|
||||
|
||||
<p/><b>Disclaimer:</b> This page is about how to do some corner-case things in
|
||||
ways you mightn’t have thought of. For an intro, please also see
|
||||
<a href="10-min.html">Miller in 10 minutes</a>.
|
||||
|
||||
<!-- ================================================================ -->
|
||||
<a id="Parsing_log-file_output"/><h1>Parsing log-file output</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_parsing_log_file_output');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_parsing_log_file_output" style="display: block">
|
||||
|
||||
<p/>This, of course, depends highly on what’s in your log files. But, as
|
||||
an example, suppose you have log-file lines such as
|
||||
|
|
@ -240,7 +246,10 @@ grep 'various sorts' *.log | sed 's/.*} //' | mlr --fs space --repifs --oxtab st
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Rectangularizing_data"/><h1>Rectangularizing data</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_rectangularizing_data');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_rectangularizing_data" style="display: block">
|
||||
|
||||
<p/>Suppose you have a method (in whatever language) which is printing things of the form
|
||||
|
||||
|
|
@ -347,7 +356,10 @@ outer=3,middle=31,inner1=313,inner2=314
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Bulk_rename_of_field_names"/><h1>Bulk rename of field names</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_bulk_rename');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_bulk_rename" style="display: block">
|
||||
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
|
|
@ -413,7 +425,10 @@ def a_b_c g_h_i
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Headerless_CSV_on_input_or_output"/><h1>Headerless CSV on input or output</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_headerless_csv');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_headerless_csv" style="display: block">
|
||||
|
||||
<p/>Sometimes we get CSV files which lack a header. For example:
|
||||
|
||||
|
|
@ -514,7 +529,10 @@ purple,triangle,0,51,0.4355354501763202,0.8591292672156728,0.8122903963006748,5.
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Regularizing_ragged_CSV"/><h1>Regularizing ragged CSV</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_rectangularizing_ragged_csv');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_rectangularizing_ragged_csv" style="display: block">
|
||||
|
||||
<p/>Miller handles compliant CSV: in particular, it’s an error if the
|
||||
number of data fields in a given data line don’t match the number of
|
||||
|
|
@ -576,7 +594,10 @@ a,b,c
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Program_timing"/><h1>Program timing</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_program_timing');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_program_timing" style="display: block">
|
||||
|
||||
This admittedly artificial example demonstrates using Miller time and stats
|
||||
functions to introspectly acquire some information about Miller’s own
|
||||
|
|
@ -618,7 +639,10 @@ t_delta_max 5.388259888e-05
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Memoization_with_out-of-stream_variables"/><h1>Memoization with out-of-stream variables</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_memoization_with_oosvars');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_memoization_with_oosvars" style="display: block">
|
||||
|
||||
<p/> The recursive function for the Fibonacci sequence is famous for its computational complexity.
|
||||
Namely, using
|
||||
|
|
@ -649,32 +673,32 @@ $ mlr --ofmt '%.9lf' --opprint seqgen --start 1 --stop 28 then put '
|
|||
i o fcount seconds_delta
|
||||
1 1 1 0
|
||||
2 2 3 0.000031948
|
||||
3 3 5 0.000012159
|
||||
4 5 9 0.000015020
|
||||
5 8 15 0.000020981
|
||||
6 13 25 0.000027895
|
||||
7 21 41 0.000044107
|
||||
8 34 67 0.000065804
|
||||
9 55 109 0.000105143
|
||||
10 89 177 0.000167847
|
||||
11 144 287 0.000271082
|
||||
12 233 465 0.000427961
|
||||
13 377 753 0.000688076
|
||||
14 610 1219 0.001102924
|
||||
15 987 1973 0.001820087
|
||||
16 1597 3193 0.002871990
|
||||
17 2584 5167 0.004658937
|
||||
18 4181 8361 0.007560968
|
||||
19 6765 13529 0.012096167
|
||||
20 10946 21891 0.019388914
|
||||
21 17711 35421 0.031304121
|
||||
22 28657 57313 0.050275803
|
||||
23 46368 92735 0.080559015
|
||||
24 75025 150049 0.136618137
|
||||
25 121393 242785 0.208474874
|
||||
26 196418 392835 0.335786104
|
||||
27 317811 635621 0.553169966
|
||||
28 514229 1028457 0.884209871
|
||||
3 3 5 0.000013113
|
||||
4 5 9 0.000014782
|
||||
5 8 15 0.000022173
|
||||
6 13 25 0.000028849
|
||||
7 21 41 0.000045061
|
||||
8 34 67 0.000067949
|
||||
9 55 109 0.000108004
|
||||
10 89 177 0.000173092
|
||||
11 144 287 0.000277996
|
||||
12 233 465 0.000439882
|
||||
13 377 753 0.000705004
|
||||
14 610 1219 0.001131058
|
||||
15 987 1973 0.001841068
|
||||
16 1597 3193 0.003005981
|
||||
17 2584 5167 0.004643917
|
||||
18 4181 8361 0.007503033
|
||||
19 6765 13529 0.012021065
|
||||
20 10946 21891 0.019377947
|
||||
21 17711 35421 0.031213999
|
||||
22 28657 57313 0.050358057
|
||||
23 46368 92735 0.080504894
|
||||
24 75025 150049 0.131229162
|
||||
25 121393 242785 0.218618870
|
||||
26 196418 392835 0.372801065
|
||||
27 317811 635621 0.605077982
|
||||
28 514229 1028457 0.981553078
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
|
@ -706,39 +730,42 @@ $ 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
|
||||
2 2 3 0.000036001
|
||||
3 3 3 0.000013113
|
||||
4 5 3 0.000010967
|
||||
4 5 3 0.000011921
|
||||
5 8 3 0.000010967
|
||||
6 13 3 0.000010014
|
||||
7 21 3 0.000010014
|
||||
8 34 3 0.000010014
|
||||
9 55 3 0.000011921
|
||||
10 89 3 0.000010014
|
||||
11 144 3 0.000010014
|
||||
12 233 3 0.000014067
|
||||
13 377 3 0.000010014
|
||||
7 21 3 0.000010967
|
||||
8 34 3 0.000010967
|
||||
9 55 3 0.000012159
|
||||
10 89 3 0.000009775
|
||||
11 144 3 0.000011206
|
||||
12 233 3 0.000013828
|
||||
13 377 3 0.000010967
|
||||
14 610 3 0.000010014
|
||||
15 987 3 0.000010014
|
||||
16 1597 3 0.000009775
|
||||
17 2584 3 0.000011206
|
||||
18 4181 3 0.000008821
|
||||
19 6765 3 0.000010014
|
||||
20 10946 3 0.000010014
|
||||
15 987 3 0.000011206
|
||||
16 1597 3 0.000010014
|
||||
17 2584 3 0.000009775
|
||||
18 4181 3 0.000010014
|
||||
19 6765 3 0.000011206
|
||||
20 10946 3 0.000009775
|
||||
21 17711 3 0.000010014
|
||||
22 28657 3 0.000010014
|
||||
23 46368 3 0.000011921
|
||||
23 46368 3 0.000013113
|
||||
24 75025 3 0.000010014
|
||||
25 121393 3 0.000011206
|
||||
26 196418 3 0.000009775
|
||||
27 317811 3 0.000010014
|
||||
25 121393 3 0.000010967
|
||||
26 196418 3 0.000010014
|
||||
27 317811 3 0.000010967
|
||||
28 514229 3 0.000010014
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Finding_missing_dates"/><h1>Finding missing dates</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_finding_missing_dates');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_finding_missing_dates" style="display: block">
|
||||
|
||||
<p/>Suppose you have some date-stamped data which may (or may not) be missing entries for one or more dates:
|
||||
|
||||
|
|
@ -849,7 +876,10 @@ n=1125,1=2015-04-05,2=182528
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Generating_random_variables"/><h1>Generating random variables</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_generating_random_variables');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_generating_random_variables" style="display: block">
|
||||
|
||||
<p/>Here can chain together a few simple building blocks:
|
||||
|
||||
|
|
@ -963,7 +993,10 @@ bin_lo bin_hi u_count s_count
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Two-pass_algorithms"/><h1>Two-pass algorithms</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_two_pass_algorithms');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_two_pass_algorithms" style="display: block">
|
||||
|
||||
<p/>Miller is a streaming record processor; commands are performed once per
|
||||
record. This makes Miller particularly suitable for single-pass algorithms,
|
||||
|
|
@ -1131,7 +1164,10 @@ green purple 5 0.203577
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Filtering_paragraphs_of_text"/><h1>Filtering paragraphs of text</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_filtering_paragraphs_of_text');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_filtering_paragraphs_of_text" style="display: block">
|
||||
|
||||
<p/>The idea is to use a record separator which is a pair of newlines. Then, if
|
||||
you want each paragraph to be a record with a single value, use a
|
||||
|
|
@ -1211,7 +1247,10 @@ falls mainly on the plain. The rain in Spain falls mainly on the plain. The
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Doing_arithmetic_on_fields_with_currency_symbols"/><h1>Doing arithmetic on fields with currency symbols</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_doing_arithmetic_with_currency_symbols');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_doing_arithmetic_with_currency_symbols" style="display: block">
|
||||
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
|
|
@ -1253,7 +1292,10 @@ Amount_sum
|
|||
<p/>
|
||||
|
||||
<!-- ================================================================ -->
|
||||
</div>
|
||||
<a id="Using_out-of-stream_variables"/><h1>Using out-of-stream variables</h1>
|
||||
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_using_oosvars');" href="javascript:;">Toggle section visibility</button>
|
||||
<div id="section_toggle_using_oosvars" style="display: block">
|
||||
|
||||
<p/> One of Miller’s strengths is its compact notation: for example, given input of the form
|
||||
|
||||
|
|
@ -1650,6 +1692,8 @@ wye pan 5 0.5732889198020006 0.8636244699032729 0.391064
|
|||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue