mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-18 17:04:50 +00:00
228 lines
8.1 KiB
HTML
228 lines
8.1 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-faq.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 -->
|
|
<meta name="keywords"
|
|
content="John Kerl, Kerl, Miller, miller, mlr, OLAP, data analysis software, regression, correlation, variance, data tools, " />
|
|
|
|
<title> FAQ </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>
|
|
|
|
<script type="text/javascript">
|
|
function toggle(divName) {
|
|
var eleDiv = document.getElementById(divName);
|
|
if (eleDiv != null) {
|
|
if (eleDiv.style.display == "block") {
|
|
eleDiv.style.display = "none";
|
|
} else {
|
|
eleDiv.style.display = "block";
|
|
}
|
|
}
|
|
}
|
|
</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%">
|
|
<!--
|
|
<img src="pix/mlr.jpg" />
|
|
<img style="border-width:1px; color:black;" src="pix/mlr.jpg" />
|
|
-->
|
|
|
|
<div class="pokinav">
|
|
<center><titleinbody>Miller</titleinbody></center>
|
|
|
|
<!-- PAGE LIST GENERATED FROM template.html BY poki -->
|
|
<br/>• <a href="index.html">About Miller</a>
|
|
<br/>• <a href="file-formats.html">File formats</a>
|
|
<br/>• <a href="feature-comparison.html">Miller features in the context of the Unix toolkit</a>
|
|
<br/>• <a href="record-heterogeneity.html">Record-heterogeneity</a>
|
|
<br/>• <a href="reference.html">Reference</a>
|
|
<br/>• <a href="data-examples.html">Data examples</a>
|
|
<br/>• <a href="faq.html"><b>FAQ</b></a>
|
|
<br/>• <a href="internationalization.html">Internationalization</a>
|
|
<br/>• <a href="build.html">Compiling, portability, dependencies, and testing</a>
|
|
<br/>• <a href="performance.html">Performance</a>
|
|
<br/>• <a href="whyc.html">Why C?</a>
|
|
<br/>• <a href="etymology.html">Why call it Miller?</a>
|
|
<br/>• <a href="originality.html">How original is Miller?</a>
|
|
<br/>• <a href="to-do.html">Things to do</a>
|
|
<br/>• <a href="contact.html">Contact information</a>
|
|
<br/>• <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>
|
|
<div style="overflow-y:scroll;height:1500px">
|
|
<center> <titleinbody> FAQ </titleinbody> </center>
|
|
<p/>
|
|
|
|
<!-- BODY COPIED FROM content-for-faq.html BY poki -->
|
|
<div class="pokitoc">
|
|
<center><b>Contents:</b></center>
|
|
• <a href="#No_output_at_all">No output at all</a><br/>
|
|
• <a href="#Fields_not_selected">Fields not selected</a><br/>
|
|
• <a href="#Error-output_in_certain_string_cases">Error-output in certain string cases</a><br/>
|
|
• <a href="#How_do_I_parse_log-file_output?">How do I parse log-file output?</a><br/>
|
|
• <a href="#How_do_I_examine_then-chaining?">How do I examine then-chaining?</a><br/>
|
|
</div>
|
|
<p/>
|
|
|
|
<a id="No_output_at_all"/><h1>No output at all</h1>
|
|
|
|
<p/>Check the line-terminators of the data, e.g. with the command-line
|
|
<tt>file</tt> program. Example: for CSV, Miller’s default line terminator
|
|
is CR/LF (carriage return followed by linefeed, following
|
|
<a href="https://tools.ietf.org/html/rfc4180">RFC4180</a>). Yet if your CSV has
|
|
*nix-standard LF line endings, Miller will keep reading the file looking for a
|
|
CR/LF which never appears. Solution in this case: tell Miller the input has LF line-terminator, e.g. <tt>mlr --csv --rs
|
|
lf {remaining arguments ...}</tt>.
|
|
|
|
<a id="Fields_not_selected"/><h1>Fields not selected</h1>
|
|
|
|
<p/>Check the field-separators of the data, e.g. with the command-line
|
|
<tt>head</tt> program. Example: for CSV, Miller’s default record
|
|
separator is comma; if your data is tab-delimited, e.g. <tt>aTABbTABc</tt>,
|
|
then Miller won’t find three fields named <tt>a</tt>, <tt>b</tt>, and
|
|
<tt>c</tt> but rather just one named <tt>aTABbTABc</tt>. Solution in this
|
|
case: <tt>mlr --fs tab {remaining arguments ...}</tt>.
|
|
|
|
<a id="Error-output_in_certain_string_cases"/><h1>Error-output in certain string cases</h1>
|
|
|
|
<p/> <tt>mlr put '$y = string($x); $z=$y.$y'</tt> gives <tt>(error)</tt> on
|
|
numeric data such as <tt>x=123</tt> while <tt>mlr put
|
|
'$z=string($x).string($x)'</tt> does not. This is because in the former case
|
|
<tt>y</tt> is computed and stored as a string, then re-parsed as an integer,
|
|
for which string-concatenation is an invalid operator.
|
|
|
|
<a id="How_do_I_parse_log-file_output?"/><h1>How do I parse log-file output?</h1>
|
|
|
|
<p/>Suppose you have log-file lines such as
|
|
|
|
<p/>
|
|
<div class="pokipanel">
|
|
<pre>
|
|
2015-10-08 08:29:09,445 INFO com.company.path.to.ClassName @ [sometext] various/sorts/of data {& punctuation} hits=1 status=0 time=2.378
|
|
</pre>
|
|
</div>
|
|
<p/>
|
|
|
|
I prefer to pre-filter with <tt>grep</tt> and/or <tt>sed</tt> to extract the structured text, then hand that to Miller. Example:
|
|
|
|
<p/>
|
|
<div class="pokipanel">
|
|
<pre>
|
|
grep 'various sorts' *.log | sed 's/.*} //' | mlr --fs space --repifs stats1 -a min,p10,p50,p90,max -f time -g status
|
|
</pre>
|
|
</div>
|
|
<p/>
|
|
|
|
<a id="How_do_I_examine_then-chaining?"/><h1>How do I examine then-chaining?</h1>
|
|
|
|
<p/>Then-chaining found in Miller is intended to function the same as Unix
|
|
pipes. You can print your data one pipeline step at a time, to see what
|
|
intermediate
|
|
output at one step becomes the input to the next step.
|
|
|
|
<p/>First, review the input data:
|
|
|
|
<p/>
|
|
<div class="pokipanel">
|
|
<pre>
|
|
$ cat data/then-example.csv
|
|
Status,Payment_Type,Amount
|
|
paid,cash,10.00
|
|
pending,debit,20.00
|
|
paid,cash,50.00
|
|
pending,credit,40.00
|
|
paid,debit,30.00
|
|
</pre>
|
|
</div>
|
|
<p/>
|
|
|
|
Next, run the first step of your command, omitting anything from the first <tt>then</tt> onward:
|
|
|
|
<p/>
|
|
<div class="pokipanel">
|
|
<pre>
|
|
$ mlr --icsv --rs lf --opprint count-distinct -f Status,Payment_Type data/then-example.csv
|
|
Status Payment_Type count
|
|
paid cash 2
|
|
pending debit 1
|
|
pending credit 1
|
|
paid debit 1
|
|
</pre>
|
|
</div>
|
|
<p/>
|
|
|
|
After that, run it with the next <tt>then</tt> step included:
|
|
|
|
<p/>
|
|
<div class="pokipanel">
|
|
<pre>
|
|
$ mlr --icsv --rs lf --opprint count-distinct -f Status,Payment_Type then sort -nr count data/then-example.csv
|
|
Status Payment_Type count
|
|
paid cash 2
|
|
pending debit 1
|
|
pending credit 1
|
|
paid debit 1
|
|
</pre>
|
|
</div>
|
|
<p/>
|
|
|
|
Now if you include another <tt>then</tt> step after this, the columns <tt>Status</tt>,
|
|
<tt>Payment_Type</tt>, and <tt>count</tt> will be its input.
|
|
|
|
<p/>Note, by the way, that you’ll get the same results using pipes:
|
|
<p/>
|
|
<div class="pokipanel">
|
|
<pre>
|
|
$ mlr --csv --rs lf count-distinct -f Status,Payment_Type data/then-example.csv | mlr --icsv --rs lf --opprint sort -nr count
|
|
Status Payment_Type count
|
|
paid cash 2
|
|
pending debit 1
|
|
pending credit 1
|
|
paid debit 1
|
|
</pre>
|
|
</div>
|
|
<p/>
|
|
</div>
|
|
</td>
|
|
|
|
</table>
|
|
</body>
|
|
</html>
|