https://stackoverflow.com/questions/29642102/how-to-make-awk-ignore-the-field-delimiter-inside-double-quotes
On Sun, May 21, 2023 at 1:05 PM Russell Senior <russ...@personaltelco.net> wrote: > Rich Shepard <rshep...@appl-ecosys.com> 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 > russ...@personaltelco.net >