I have the following CSV file:
ID,COUNTRY,DESCRIPTION,PRICE
1,USA,Short description,11
2,UK,"Description with comma , inside",2.3
So if field contains comma, it is put in double quotes.
How to replace delimiter from comma to tabulator but ignore commas in quotes? So I will have:
ID COUNTRY DESCRIPTION PRICE
1 USA Short description 11
2 UK "Description with comma , inside" 2.3
or without double quotes:
ID COUNTRY DESCRIPTION PRICE
1 USA Short description 11
2 UK Description with comma , inside 2.3
I use this code before I noticed that some fields contain commas:
$VAR='\t'
sed -i $"s/,/$VAR/" $FILE_NAME