如何从 CSV 文件中删除具有逗号分隔值的列,其中字符串用双引号括起来,中间有逗号?我有一个 44.csv 文件,它有 4 行,包括如下格式的标题:
column1, column2, column3, column 4, column5, column6
12,455,"string with quotes, and with a comma in between",4432,6787,890,88
4432,6787,"another, string with quotes, and with two comma in between",890,88,12,455
11,22,"simple string",77,777,333,22
我需要从文件中剪切 1,2,3 列,所以我使用如下剪切命令
cut -d"," -f1,2,3 44.csv > 444.csv
我得到的输出为
column1, column2, column3
12,455,"string with quotes
4432,6787,"another string with quotes
11,22,"simple string"
但我需要输出
column1, column2, column3
12,455,"string with quotes, and with a comma in between"
4432,6787,"another, string with quotes, and with two comma in between"
11,22,"simple string"
任何帮助是极大的赞赏。
谢谢德鲁夫。