Parsing a CSV file using gawk

后端 未结 9 1227
感动是毒
感动是毒 2020-11-29 12:12

How do you parse a CSV file using gawk? Simply setting FS=\",\" is not enough, as a quoted field with a comma inside will be treated as multiple fields.

<
9条回答
  •  独厮守ぢ
    2020-11-29 12:32

    The gawk version 4 manual says to use FPAT = "([^,]*)|(\"[^\"]+\")"

    When FPAT is defined, it disables FS and specifies fields by content instead of by separator.

提交回复
热议问题