[lug] awk question

Harris, James James_Harris at maxtor.com
Mon Jan 27 14:03:59 MST 2003


Hi all --

Kinda stumped here.  I have a .csv file that I need to parse (using awk,
preferably) that uses quotes to protect "real" commas in the data.  How can
I deal with this in awk?  I've dug around the awk documentation and the
closest idea that I have is to compose some type of regex for it, but I'm
also stumped on how I would describe this scenerio with a regex?

How can I tell awk that ',' is the FS except when found within ""?  Is this
going to be a portentially huge nightmare?  Perl really isn't an option cuz
I don't know it (and don't really have the time to learn it -- reason #2,345
that I need to learn perl).  The option to re-export the data with another
FS is there, but not easy or quick... so if I can tell awk to deal with it
quickly, then it's worth it, otherwise I'll take the human and compute
cycles to re-export it.

Thanks all,
Jim



More information about the LUG mailing list