miller/doc/feature-comparison.html
2015-05-03 16:41:29 -07:00

163 lines
5.7 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<!-- PAGE GENERATED FROM template.html and content-for-feature-comparison.html BY poki. -->
<!-- PLEASE MAKE CHANGES THERE AND THEN RE-RUN poki. -->
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
<meta name="description" content="Miller documentation"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <!-- mobile-friendly -->
<title> Miller features in the context of the Unix toolkit </title>
<link rel="stylesheet" type="text/css" href="css/miller.css"/>
<link rel="stylesheet" type="text/css" href="css/poki-callbacks.css"/>
</head>
<!-- ================================================================ -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-15651652-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<!--
The background image is from a screenshot of a Google search for "data analysis
tools", lightened and sepia-toned. Over this was placed a Mac Terminal app with
very light-grey font and translucent background, in which a few statistical
Miller commands were run with pretty-print-tabular output format.
-->
<body background="pix/sepia-overlay.jpg">
<!-- ================================================================ -->
<table width="100%">
<tr>
<!-- navbar -->
<td width="15%">
<div class="pokinav">
<center><titleinbody>Miller</titleinbody></center>
<!-- PAGE LIST GENERATED FROM template.html BY poki -->
<br/>User info:
<br/>&bull;&nbsp;<a href="index.html">About</a>
<br/>&bull;&nbsp;<a href="file-formats.html">File formats</a>
<br/>&bull;&nbsp;<a href="feature-comparison.html">Miller features in the context of the Unix toolkit</a>
<br/>&bull;&nbsp;<a href="record-heterogeneity.html">Record-heterogeneity</a>
<br/>&bull;&nbsp;<a href="performance.html">Performance</a>
<br/>&bull;&nbsp;<a href="etymology.html">Why call it Miller?</a>
<br/>&bull;&nbsp;<a href="originality.html">How original is Miller?</a>
<br/>&bull;&nbsp;<a href="reference.html">Reference</a>
<br/>&bull;&nbsp;<a href="data-examples.html">Data examples</a>
<br/>&bull;&nbsp;<a href="to-do.html">Things to do</a>
<br/>Developer info:
<br/>&bull;&nbsp;<a href="build.html">Compiling, portability, dependencies, and testing</a>
<br/>&bull;&nbsp;<a href="whyc.html">Why C?</a>
<br/>&bull;&nbsp;<a href="contact.html">Contact information</a>
<br/>&bull;&nbsp;<a href="https://github.com/johnkerl/miller">GitHub repo</a>
<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/>
<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/>
<br/> <br/> <br/> <br/> <br/> <br/>
</div>
</td>
<!-- page body -->
<td>
<center> <titleinbody> Miller features in the context of the Unix toolkit </titleinbody> </center>
<p>
<!-- BODY COPIED FROM content-for-feature-comparison.html BY poki -->
<div class="pokitoc">
<center><b>Contents:</b></center>
&bull;&nbsp;<a href="#File-format_awareness">File-format awareness</a><br/>
&bull;&nbsp;<a href="#awk-like_features:_mlr_filter_and_mlr_put">awk-like features: mlr filter and mlr put</a><br/>
&bull;&nbsp;<a href="#See_also">See also</a><br/>
</div>
<p/>
<h1>File-format awareness</h1> <a id="File-format_awareness"/>
Miller respects CSV headers. If you do <tt>mlr --csv-input cat *.csv</tt> then the header line is written once:
<table><tr>
<td>
<p/>
<div class="pokipanel">
<pre>
$ cat a.csv
a,b,c
1,2,3
4,5,6
</pre>
</div>
<p/>
</td>
<td>
<p/>
<div class="pokipanel">
<pre>
$ cat b.csv
a,b,c
7,8,9
</pre>
</div>
<p/>
</td>
<td>
<p/>
<div class="pokipanel">
<pre>
$ mlr --csv cat a.csv b.csv
a,b,c
1,2,3
4,5,6
7,8,9
</pre>
</div>
<p/>
</td>
</tr></table>
Likewise with <tt>mlr sort</tt>, <tt>mlr tac</tt>, and so on.
<h1>awk-like features: mlr filter and mlr put</h1> <a id="awk-like_features:_mlr_filter_and_mlr_put"/>
<ul>
<li/> <tt>mlr filter</tt> includes/excludes records based on a filter
expression, e.g. <tt>mlr filter '$count &gt; 10'</tt>.
<li/> <tt>mlr put</tt> adds a new field as a function of others, e.g. <tt>mlr
put '$xy = $x * $y'</tt> or <tt>mlr put '$counter = NR'</tt>.
<li/> The <tt>$name</tt> syntax is straight from <tt>awk</tt>&rsquo;s <tt>$1 $2
$3</tt> (adapted to name-based indexing), as are the variables <tt>FS</tt>,
<tt>OFS</tt>, <tt>RS</tt>, <tt>ORS</tt>, <tt>NF</tt>, <tt>NR</tt>, and
<tt>FILENAME</tt>.
<li/> While <tt>awk</tt> functions are record-based, Miller subcommands (or
functions, if you like) are stream-based: each of them maps a stream of records
into another stream of records.
<li/> Unlike <tt>awk</tt>, Miller doesn&rsquo;t allow you to define new functions.
Its domain-specific languages are limited to the <tt>filter</tt> and
<tt>put</tt> syntax. Futher programmability comes from chaining with
<tt>then</tt>.
<li/> Miller is faster than <tt>awk</tt>, <tt>cut</tt>, and so on (depending on
platform; see also <a href="performance.html">Performance</a>). In
particular, Miller&rsquo;s DSL syntax is parsed into C control structures at
startup time, with the bulk data-stream processing all done in C.
</ul>
<h1>See also</h1> <a id="See_also"/>
<p/>See <a href="reference.html">Reference</a> for more on Miller&rsquo;s
subcommands <tt>cat</tt>, <tt>cut</tt>, <tt>head</tt>, <tt>sort</tt>,
<tt>tac</tt>, <tt>tail</tt>, <tt>top</tt>, and <tt>uniq</tt>, as well as awk-like
<tt>mlr filter</tt> and <tt>mlr put</tt>.
</td>
</table>
</body>
</html>