Hi All,
I am getting .csv file whenever there is a comma present between a field that field get enclosed with double quotes
For eg as below
abc,123,xxyy,2178
fgh,123,"x,x"yy",2178
ghi,123,"x,xyy",2178
jkl,123,xx"yy,2178
whereas I want my data as per below
abc,123,xxyy,2178
fgh,123,xx"yy,2178
ghi,123,xxyy,2178
jkl,123,xx"yy,2178
I ran the following code
awk -F'"' -v OFS='' '{ for (i=2; i<=NF; i+=2) gsub(",", "", $i) } 1' test.csv
If quotes are unbalanced it removes all the valid commas after it finds first quotes.
Can you please help me with this.
Thanks,
Bansal