mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-18 00:45:47 +00:00
mlr nest example at cookbook
This commit is contained in:
parent
8bba88aa19
commit
73d683d59a
2 changed files with 38 additions and 0 deletions
|
|
@ -146,6 +146,14 @@ POKI_RUN_COMMAND_TOLERATING_ERROR{{mlr --csv put '$reachable = asserting_string(
|
|||
|
||||
POKI_INCLUDE_ESCAPED(data/nested.tsv)HERE
|
||||
|
||||
<p/> The simplest option is to use <a href="reference-verbs.html#nest"><tt>mlr nest</tt></a>:
|
||||
|
||||
POKI_RUN_COMMAND{{mlr --tsv nest --explode --values --across-records -f b --nested-fs : data/nested.tsv}}HERE
|
||||
POKI_RUN_COMMAND{{mlr --tsv nest --explode --values --across-fields -f b --nested-fs : data/nested.tsv}}HERE
|
||||
|
||||
<p/> While <tt>mlr nest</tt> is simplest, let’s also take a look at a few ways to do this using the
|
||||
<tt>put</tt> DSL.
|
||||
|
||||
<p/> One option to split out the colon-delimited values in the <tt>b</tt>
|
||||
column is to use <tt>splitnv</tt> to create an integer-indexed map and loop
|
||||
over it, adding new fields to the current record:
|
||||
|
|
|
|||
|
|
@ -633,6 +633,36 @@ s u:v:w
|
|||
</div>
|
||||
<p/>
|
||||
|
||||
<p/> The simplest option is to use <a href="reference-verbs.html#nest"><tt>mlr nest</tt></a>:
|
||||
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
<pre>
|
||||
$ mlr --tsv nest --explode --values --across-records -f b --nested-fs : data/nested.tsv
|
||||
a b
|
||||
x z
|
||||
s u
|
||||
s v
|
||||
s w
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
<p/>
|
||||
<div class="pokipanel">
|
||||
<pre>
|
||||
$ mlr --tsv nest --explode --values --across-fields -f b --nested-fs : data/nested.tsv
|
||||
a b_1
|
||||
x z
|
||||
|
||||
a b_1 b_2 b_3
|
||||
s u v w
|
||||
</pre>
|
||||
</div>
|
||||
<p/>
|
||||
|
||||
<p/> While <tt>mlr nest</tt> is simplest, let’s also take a look at a few ways to do this using the
|
||||
<tt>put</tt> DSL.
|
||||
|
||||
<p/> One option to split out the colon-delimited values in the <tt>b</tt>
|
||||
column is to use <tt>splitnv</tt> to create an integer-indexed map and loop
|
||||
over it, adding new fields to the current record:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue