miller/docs6/docs/_build/html/reference-dsl-unset-statements.html

119 lines
No EOL
5.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DSL reference: unset statements &#8212; 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="DSL reference: filter statements" href="reference-dsl-filter-statements.html" />
<link rel="prev" title="DSL reference: output statements" href="reference-dsl-output-statements.html" />
</head><body>
<div id="content">
<div class="header">
<h1 class="heading"><a href="index.html"
title="back to the documentation overview"><span>DSL reference: unset statements</span></a></h1>
</div>
<div class="relnav" role="navigation" aria-label="related navigation">
<a href="reference-dsl-output-statements.html">&laquo; DSL reference: output statements</a> |
<a href="#">DSL reference: unset statements</a>
| <a href="reference-dsl-filter-statements.html">DSL reference: filter statements &raquo;</a>
</div>
<div id="contentwrapper">
<div role="main">
<div class="section" id="dsl-reference-unset-statements">
<h1>DSL reference: unset statements<a class="headerlink" href="#dsl-reference-unset-statements" title="Permalink to this headline"></a></h1>
<p>You can clear a map key by assigning the empty string as its value: <code class="docutils literal notranslate"><span class="pre">$x=&quot;&quot;</span></code> or <code class="docutils literal notranslate"><span class="pre">&#64;x=&quot;&quot;</span></code>. Using <code class="docutils literal notranslate"><span class="pre">unset</span></code> you can remove the key entirely. Examples:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> cat data/small
</span> a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533
a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797
a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776
a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463
a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr put &#39;unset $x, $a&#39; data/small
</span> b=pan,i=1,y=0.7268028627434533
b=pan,i=2,y=0.5221511083334797
b=wye,i=3,y=0.33831852551664776
b=wye,i=4,y=0.13418874328430463
b=pan,i=5,y=0.8636244699032729
</pre></div>
</div>
<p>This can also be done, of course, using <code class="docutils literal notranslate"><span class="pre">mlr</span> <span class="pre">cut</span> <span class="pre">-x</span></code>. You can also clear out-of-stream or local variables, at the base name level, or at an indexed sublevel:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr put -q &#39;@sum[$a][$b] += $x; end { dump; unset @sum; dump }&#39; data/small
</span> {
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.3467901443380824
},
&quot;eks&quot;: {
&quot;pan&quot;: 0.7586799647899636,
&quot;wye&quot;: 0.38139939387114097
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.20460330576630303,
&quot;pan&quot;: 0.5732889198020006
}
}
}
{}
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><span class="hll"> mlr put -q &#39;@sum[$a][$b] += $x; end { dump; unset @sum[&quot;eks&quot;]; dump }&#39; data/small
</span> {
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.3467901443380824
},
&quot;eks&quot;: {
&quot;pan&quot;: 0.7586799647899636,
&quot;wye&quot;: 0.38139939387114097
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.20460330576630303,
&quot;pan&quot;: 0.5732889198020006
}
}
}
{
&quot;sum&quot;: {
&quot;pan&quot;: {
&quot;pan&quot;: 0.3467901443380824
},
&quot;wye&quot;: {
&quot;wye&quot;: 0.20460330576630303,
&quot;pan&quot;: 0.5732889198020006
}
}
}
</pre></div>
</div>
<p>If you use <code class="docutils literal notranslate"><span class="pre">unset</span> <span class="pre">all</span></code> (or <code class="docutils literal notranslate"><span class="pre">unset</span> <span class="pre">&#64;*</span></code> which is synonymous), that will unset all out-of-stream variables which have been defined up to that point.</p>
</div>
</div>
</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2021, John Kerl.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>