[TUHS] Awk for CSV files

arnold at skeeve.com arnold at skeeve.com
Mon Oct 14 00:57:31 AEST 2019


Awk and csv isn't new. Googling 'awk csv' gets you a bunch of results.

There is also the 'csv' dynamically loadable extension for gawk to
be found in the gawkextlib project.  Contact me off-list if you want
more details.

Thanks,

Arnold

Richard Tobin <richard at inf.ed.ac.uk> wrote:

> I was reminded of this by Larry's comment:
>
> > I miss Brian on this list.  I've interacted with him over the years, the
> > one I remember the most was I was trying to do an awk like interface to a
> > key/value "database".
>
> Recently I've had to deal with a lot of data in CSV
> (comma-separated-value) format.  Awk is *almost* prefect for this, but
> of course doesn't handle the quoting of fields that contain commas.
> One can usually work around it by finding a character that doesn't
> occur in the data and converting the CSV file to use that as the
> separator, but it's not ideal.
>
> Awk's input could easily be modified to handle CSV files, but output
> would be a bit more difficult, because you don't specify field
> boundaries explicitly on output.  One possibility would be a printf()
> format specifier that takes a field and quotes it appropriately.
>
> -- Richard
>
> -- 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.


More information about the TUHS mailing list