Rich Shepard <[email protected]> writes:
> I download .csv files from agency databases where strings are double quoted
> and contain commas within them, as well as using commas to separated fields.
>
> I start my gawk script with
> BEGIN { FS="," }
> and it separates (or counts, or selects) fields ignoring commas within
> quoted strings.
a) gawk DOES NOT do anything magical about "quoted" delimiters.
b) -F, in the command line and FS="," in the script are equivalent.
$ cat /tmp/test.csv
A,B,C
D,"e,f,g",F
$ gawk 'BEGIN { FS="," } { print NF,$0 }' /tmp/test.csv
3 A,B,C
5 D,"e,f,g",F
Please note the number of fields computed: gawk IS NOT ignoring commas
within quoted strings.
--
Russell Senior
[email protected]