I have a CSV file that is missing quotes around a column that contains text with commas. Example:
Column1, Column2, Column3, Column4, Column5, Column6
Data1, Data2, Data3, Data, 4, Data5, Data6
Data1, Data3, Data3, Data, text, 4, Data5, Data6
I think the easiest way for me to fix this is to replace the 3rd instance of a comma with a comma quote using the following sed command:
sed 's/,/,"/3' myfile.csv
The problem is that the 4th column has an unknown number of commas, so to provide the matching quote mark, I have to replace the 2nd to last instance of a comma with a quote comma. Unfortunately, I cannot figure out how to do this.
Suggestions?
Thanks.