Problems sorting a CSV with sort

Johnny Rosenberg gurus.knugum at gmail.com
Wed Sep 4 19:40:31 UTC 2013


2013/8/9 Johnny Rosenberg <gurus.knugum at gmail.com>

> 2013/8/9 Tony Arnold <tony.arnold at manchester.ac.uk>:
> > Johnny,
> >
> > Just played with csvtool.
> >
> > You could use it to replace the , field separators with TABs, say, pipe
> > through sort specifying TAB as the field delimiter and then pipe through
> > csvtool again to convert the fileds separators back to commas. E.g.:
> >
> > csvtool -t ',' -u TAB cat input.csv | sort -f 2 -t '    ' | csvtool -t
> TAB
> > -u ',' cat - > output.csv
> >
> > Not tried the above so it may need adjusting, but I think you should get
> > the idea.
> >
> > Regards,
> > Tony.
>
> Thanks! I'll take a closer look at that csvtool later. Looks promising
> so far, at least.
>
>
> Johnny Rosenberg
>

Have been playing around with it now. It seems to work but there is one
downside: It doesn't seem to support pipes…
SomeCommand | csvtool -t ',' -u TAB | sort…    # Not supported…?

Well, I don't need to use pipes, but it would be more convenient. Now I
need to create at least one temp file, which isn't a big problem, but
still… One can always wish for more…


Johnny Rosenberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20130904/913cc566/attachment.html>


More information about the ubuntu-users mailing list