I have a text file where each field is enclosed in double quotes and separated by a comma.
But in certain rows we have embedded double quotes within column data
For e.g
"""TRUSPICE CENTRE"" CLAYTON AU"
The above value is for a single column but there are embedded quotes within it - which is - ""TRUSPICE CENTRE""
How do I handle this?
I need to remove such embedded quotes if it is present and retain the enclosed quotes.
So the output I need is:
"TRUSPICE CENTRE CLAYTON AU"
Hello abhilashnair,
Please use code tags for commands/codes you are using in your posts. Please refer the forum rules in following link.
Following code may help you in same.
awk '{gsub(/\"\"/,X,$0);print}' Input_file
Output will be as follows.
"TRUSPICE CENTRE CLAYTON AU"
EDIT: Adding a solution with sed
also.
sed 's/\"\{2\}//g' Input_file
Thanks,
R. Singh
Or, since there is nothing special about double quotes in an RE and double quotes don't need to be escaped inside single quotes:
sed 's/""//g' file
or:
awk '{gsub(/""/, X, $0);print} file
or even:
awk 'gsub(/""/, "")+1' file