miller/doc/content-for-data-sharing.html
2017-10-30 10:45:57 -04:00

58 lines
2 KiB
HTML

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/> As discussed in the section on
POKI_PUT_LINK_FOR_PAGE(file-formats.html)HERE, Miller supports several
different file formats. Different tools are good at different things, so
it&rsquo;s important to be able to move data into and out of other languages.
<b>CSV</b> and <b>JSON</b> are well-known, of course; here are some examples
using <b>DKVP</b> format, with <b>Ruby</b> and <b>Python</b>.
<h1>DKVP I/O in Python</h1>
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_dkvp_python');" href="javascript:;">Toggle section visibility</button>
<div id="section_toggle_dkvp_python" style="display: block">
<p/>
Here are the I/O routines:
POKI_INCLUDE_ESCAPED(polyglot-dkvp-io/dkvp_io.py)HERE
And here is an example using them:
POKI_RUN_COMMAND{{cat polyglot-dkvp-io/example.py}}HERE
Run as-is:
POKI_RUN_COMMAND{{python polyglot-dkvp-io/example.py < data/small}}HERE
Run as-is, then pipe to Miller for pretty-printing:
POKI_RUN_COMMAND{{python polyglot-dkvp-io/example.py < data/small | mlr --opprint cat}}HERE
</div>
<h1>DKVP I/O in Ruby</h1>
<button style="font-weight:bold;color:maroon;border:0" padding=0 onclick="toggle_by_name('section_toggle_dkvp_ruby');" href="javascript:;">Toggle section visibility</button>
<div id="section_toggle_dkvp_ruby" style="display: block">
<p/>
Here are the I/O routines:
POKI_INCLUDE_ESCAPED(polyglot-dkvp-io/dkvp_io.rb)HERE
And here is an example using them:
POKI_RUN_COMMAND{{cat polyglot-dkvp-io/example.rb}}HERE
Run as-is:
POKI_RUN_COMMAND{{ruby -I./polyglot-dkvp-io polyglot-dkvp-io/example.rb data/small}}HERE
Run as-is, then pipe to Miller for pretty-printing:
POKI_RUN_COMMAND{{ruby -I./polyglot-dkvp-io polyglot-dkvp-io/example.rb data/small | mlr --opprint cat}}HERE
</div>