> which led me to this solution: > fix () perl6 -e ' > lines.classify(*.split(",").head(2)).pairs.map: { > .say for .key, |.value.map({ "\t" ~ .key }); > } > '
Hi Marc, I tried the first solution you posted and the "subheaders" are returned out of order (e.g. "2,1,3" and not "1,2,3"): mbook:~ homedir$ cat p6_chunk_csv.p6 lines.classify(*.split(",").head(2)).pairs.map: { .say for .key, |.value.map({ "\t" ~ .key }); } mbook:~ homedir$ cat awk_test1.csv | perl6 p6_chunk_csv.p6 B 3 1 2 A 2 3 1 mbook:~ homedir$ HTH, Bill. On Fri, Nov 22, 2019 at 9:13 AM Marc Chantreux <e...@phear.org> wrote: > > hello Timo, > > > lines()>>.trim-leading.classify(*.split(",").head(2)); say to-json %foo' > > which led me to this solution: > > fix () perl6 -e ' > lines.classify(*.split(",").head(2)).pairs.map: { > .say for .key, |.value.map({ "\t" ~ .key }); > } > ' > > fix () perl6 -e ' > lines\ > .classify( *.split(",").head(2) ) > .pairs > .map: { .say for .key, |.value.map({ "\t" ~ .key }); } > ' > > which is nice to read but hold much more data in memory. > anyway: good point. > > regards > marc