mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-24 02:36:15 +00:00
122 lines
No EOL
7.1 KiB
HTML
122 lines
No EOL
7.1 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>Reference: Miller commands — Miller 6.0.0-alpha documentation</title>
|
||
|
||
<link rel="stylesheet" href="_static/scrolls.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/print.css" type="text/css" />
|
||
|
||
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||
<script src="_static/jquery.js"></script>
|
||
<script src="_static/underscore.js"></script>
|
||
<script src="_static/doctools.js"></script>
|
||
<script src="_static/language_data.js"></script>
|
||
<script src="_static/theme_extras.js"></script>
|
||
<link rel="index" title="Index" href="genindex.html" />
|
||
<link rel="search" title="Search" href="search.html" />
|
||
<link rel="next" title="Reference: list of verbs" href="reference-verbs.html" />
|
||
<link rel="prev" title="Performance" href="performance.html" />
|
||
</head><body>
|
||
<div id="content">
|
||
<div class="header">
|
||
<h1 class="heading"><a href="index.html"
|
||
title="back to the documentation overview"><span>Reference: Miller commands</span></a></h1>
|
||
</div>
|
||
<div class="relnav" role="navigation" aria-label="related navigation">
|
||
<a href="performance.html">« Performance</a> |
|
||
<a href="#">Reference: Miller commands</a>
|
||
| <a href="reference-verbs.html">Reference: list of verbs »</a>
|
||
</div>
|
||
<div id="contentwrapper">
|
||
<div id="toc" role="navigation" aria-label="table of contents navigation">
|
||
<h3>Table of Contents</h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Reference: Miller commands</a><ul>
|
||
<li><a class="reference internal" href="#overview">Overview</a></li>
|
||
<li><a class="reference internal" href="#verbs-vs-dsl">Verbs vs DSL</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
<div role="main">
|
||
|
||
<div class="section" id="reference-miller-commands">
|
||
<h1>Reference: Miller commands<a class="headerlink" href="#reference-miller-commands" title="Permalink to this headline">¶</a></h1>
|
||
<div class="section" id="overview">
|
||
<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h2>
|
||
<p>The outline of an invocation of Miller is</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">mlr</span></code></p></li>
|
||
<li><p>Options controlling input/output formatting, etc. (<a class="reference internal" href="reference-main-io-options.html"><span class="doc">Reference: I/O options</span></a>).</p></li>
|
||
<li><p>One or more verbs (such as <code class="docutils literal notranslate"><span class="pre">cut</span></code>, <code class="docutils literal notranslate"><span class="pre">sort</span></code>, etc.) (<a class="reference internal" href="reference-verbs.html"><span class="doc">Reference: list of verbs</span></a>) – chained together using <code class="docutils literal notranslate"><span class="pre">then</span></code> (<a class="reference internal" href="reference-main-then-chaining.html"><span class="doc">Reference: then-chaining</span></a>). You use these to transform your data.</p></li>
|
||
<li><p>Zero or more filenames, with input taken from standard input if there are no filenames present.</p></li>
|
||
</ul>
|
||
<p>For example, reading from a file:</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr --icsv --opprint head -n 2 then sort -f shape example.csv
|
||
</span> color shape flag index quantity rate
|
||
red square true 15 79.2778 0.0130
|
||
yellow triangle true 11 43.6498 9.8870
|
||
</pre></div>
|
||
</div>
|
||
<p>Reading from standard input:</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> cat example.csv | mlr --icsv --opprint head -n 2 then sort -f shape
|
||
</span> color shape flag index quantity rate
|
||
red square true 15 79.2778 0.0130
|
||
yellow triangle true 11 43.6498 9.8870
|
||
</pre></div>
|
||
</div>
|
||
<p>The rest of this reference section gives you full information on each of these parts of the command line.</p>
|
||
</div>
|
||
<div class="section" id="verbs-vs-dsl">
|
||
<h2>Verbs vs DSL<a class="headerlink" href="#verbs-vs-dsl" title="Permalink to this headline">¶</a></h2>
|
||
<p>When you type <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">{something}</span> <span class="pre">myfile.dat</span></code>, the <code class="docutils literal notranslate"><span class="pre">{something}</span></code> part is called a <strong>verb</strong>. It specifies how you want to transform your data. Most of the verbs are counterparts of built-in system tools like <code class="docutils literal notranslate"><span class="pre">cut</span></code> and <code class="docutils literal notranslate"><span class="pre">sort</span></code> – but with file-format awareness, and giving you the ability to refer to fields by name.</p>
|
||
<p>The verbs <code class="docutils literal notranslate"><span class="pre">put</span></code> and <code class="docutils literal notranslate"><span class="pre">filter</span></code> are special in that they have a rich expression language (domain-specific language, or “DSL”). More information about them can be found at <a class="reference internal" href="reference-dsl.html"><span class="doc">DSL reference: overview</span></a>.</p>
|
||
<p>Here’s a comparison of verbs and <code class="docutils literal notranslate"><span class="pre">put</span></code>/<code class="docutils literal notranslate"><span class="pre">filter</span></code> DSL expressions:</p>
|
||
<p>Example of using a verb for data processing:</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr stats1 -a sum -f x -g a data/small
|
||
</span> a=pan,x_sum=0.3467901443380824
|
||
a=eks,x_sum=1.1400793586611044
|
||
a=wye,x_sum=0.7778922255683036
|
||
</pre></div>
|
||
</div>
|
||
<ul class="simple">
|
||
<li><p>Verbs are coded in Go</p></li>
|
||
<li><p>They run a bit faster</p></li>
|
||
<li><p>They take fewer keystrokes</p></li>
|
||
<li><p>There’s less to learn</p></li>
|
||
<li><p>Their customization is limited to each verb’s options</p></li>
|
||
</ul>
|
||
<p>Example of doing the same thing using a DSL expression:</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr put -q '@x_sum[$a] += $x; end{emit @x_sum, "a"}' data/small
|
||
</span> a=pan,x_sum=0.3467901443380824
|
||
a=eks,x_sum=1.1400793586611044
|
||
a=wye,x_sum=0.7778922255683036
|
||
</pre></div>
|
||
</div>
|
||
<ul class="simple">
|
||
<li><p>You get to write your own expressions in Miller’s programming language</p></li>
|
||
<li><p>They run a bit slower</p></li>
|
||
<li><p>They take more keystrokes</p></li>
|
||
<li><p>There’s more to learn</p></li>
|
||
<li><p>They’re highly customizable</p></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2021, John Kerl.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |