double quote as the delimiter

I'm trying to extract a column from a csv file with either cut or awk but some of the fields contain comma with them:

"Field1","Field2, additional info","Field3",...,"Field17",...

If I want to extract column 3 and use comma as the delimiter, I'll actually get the additional info bit but not Field3:

cut -f3 d, file

Is there any way to specify the double quote as the delimiter instead of comma?

Thank you.

Why cant you tell awk to extract the 4th field...which really is "Field 3" in your input data.

Because the number of additional info, hence the number of commas, vary from line to line and there are well over 40k lines

cut can't split on more than one character in a row, but awk can. I'd split on "," doing this:

awk -v FS="\",\"" '{ print "\"" $2 "\"" }' < datafile

The

"\""

are to put the deleted double-quotes back in. Leave them out if you don't care.

The first quote in the first field, and the last quote in the last field, won't be deleted.

The back slash!! :stuck_out_tongue: I actually tired FS=""," but didn't work. Now it is working. Thanks a lot.