inline:
On Fri, Nov 22, 2019 at 7:20 AM Bruce Gray <robertbrucegr...@gmail.com> wrote:
>
>
>
> > On Nov 22, 2019, at 9:06 AM, Marc Chantreux <e...@phear.org> wrote:
> >
> > hello,
> >
> > On Fri, Nov 22, 2019 at 03:07:28PM +0100, Patrick Spek via perl6-users 
> > wrote:
> >> Could you post some input and expected output? That would make it
> >> easier for me (and perhaps others) to see what exactly you're trying to
> >> accomplish, in practical terms.
> >
> > sorry ... i'm so confortable with awk i haven't though about some are
> > not. i sincerely apologize.
> >
> > Basically i want to figure out what are the sections, subsections of of
> > a CSV file:
> >
> >    A,1,garbage .....
> >    A,2,garbage .....
> >    A,2,garbage .....
> >    A,2,garbage .....
> >    A,3,garbage .....
> >    A,3,garbage .....
> >    A,3,garbage .....
> >    B,1,garbage .....
> >    B,2,garbage .....
> >    B,2,garbage .....
> >    B,2,garbage .....
> >    B,3,garbage .....
> >    B,3,garbage .....
> >    B,3,garbage .....
> >
> > becomes
> >
> >    A
> >        1
> >        2
> >        3
> >    B
> >        1
> >        2
> >        3
> >
> > regards,
> > marc
>
> Marc,
>
> When I run your original Awk code against the .csv data you listed above, I 
> get this output:
> A
>         2
>         3
> B
>         2
>         3
> The first key of each second level is missing, which differs from your sample 
> output above.
> Have I corrupted your Awk code, or have I misunderstood something, or what?
>
> --
> Thank you,
> Bruce Gray (Util of PerlMonks)

I get the same result using awk as Bruce, although I unpacked Marc's
awk code into a (long) one-liner:

mbook:~ homedir$ cat awk_test1.csv | awk -F, '{print $1"     "$2}' |
sort -u |  awk -F" " '{if   (seen == $1) print "\t"$2; else { seen =
$1; print $1 }}'
A
          2
          3
B
          2
          3
mbook:~ homedir$

HTH, Bill.

Reply via email to