miller icon indicating copy to clipboard operation
miller copied to clipboard

nest --explode -f: Support multiple fields [feature request]

Open sjackman opened this issue 4 years ago • 2 comments

It'd be useful to me for nest --explode to support multiple fields. For example

Actual output

❯❯❯ mlr nest --explode --values --across-records -f x,y <<<'x=a;b;c,y=1;2;3'
x=a;b;c,y=1;2;3

Desired output

❯❯❯ mlr nest --explode --values --across-records -f x,y <<<'x=a;b;c,y=1;2;3'
x=a,y=1
x=b,y=2
x=c,y=3

Thanks again for Miller, John!

sjackman avatar Jun 03 '21 22:06 sjackman

hi @sjackman an off-topic note: a generic solution could be something similar to

mlr cat -n then \
label @ then \
reshape -r "[^@]" -o i,v then \
nest --explode --values --across-records -f v then \
step -a counter -f i -g i then \
cut -x -f @ then \
reshape -s i,v then \
cut -x -f i_counter<<<'x=a;b;c,y=1;2;3,z=baz;maz;caz'

aborruso avatar Jun 05 '21 08:06 aborruso

I think this could be useful also for the --implode option, instead of using -f foo to implode fields foo_1,foo_2, one could use -f foo,bar and implode fields foo and bar.

akiross avatar May 24 '23 07:05 akiross