[PLUG] Re-formatting Date in .csv Field

Tim tim-pdxlug at sentinelchicken.org
Wed Jan 26 01:12:00 UTC 2011


>    It's not Microsoft. I imported the original file in OO.o because we don't
> do Windows here, and wrote it out as a .csv file from OO.o. Each row and
> column is self-contained.

Well, yeah, but most likely the CSV format it uses is the same as what
Excel generates.

That is, if there were a newline or comma in any field, the awk script
posted earlier would choke.  The following are two perfectly valid CSV
rows, each with 8 columns:


"27,132","96-A001256","BC-0.5",5/21/1996,"pH""",8.19,,"True"
"27132","96-A001256","BC-0.5
",5/21/1996,"pH",8.19,,"True"


Basically, any simple "split()" approach, which is commonly availble
in scripting languages, won't work in the general case.  But if you're
sure your data is clean, it should work with the awk script.

tim



More information about the PLUG mailing list