I'm looking for a command which can remove one/two double quotes from a CSV format file and comma's inside them to be substituted with space so that the whole field can look like one.
Ex: ""Wembley,London""
to be shown as Wembley London
under one column in the csv.
Also, the command for "Wembley,London" as Wembley London. Irrespective of the field position the script would be reading the file.
I tried the below commands but its not useful.
sed 's/\"//g' $fname > $Target/sample_UPS1.csv
sed 's/\,/ /g' $Target/sample_UPS1.csv > $Target/sample_UPS1.csv
awk -F'""' -v OFS='' '{ for (i=2; i<=NF; i+=2) gsub(",", " ", $i) } 1' $fname | sed 's/\"//g' > $Target/sample_UPS.txt ##For removal of two double quotes and substitution of comma with a space##
awk -F'"' -v OFS='' '{ for (i=2; i<=NF; i+=2) gsub(",", " ", $i) } 1' $Target/sample_UPS.txt | sed 's/\"//g' > $Target/sample_UPS1.txt ##For removal of double quotes and substitution of comma with a space##
Both the cases, sample_ups1 being my output file.
awk -F'"' -v OFS='' '{ for (i=2; i<=NF; i+=2) gsub(",", " ", $i) } 1' file
– Siva Aug 28 '18 at 13:27awk -F'"' -v OFS='' '{gsub (/""/, "\""); for (i=2; i<=NF; i+=2) gsub(",", " ", $i) } 1' file
– RudiC Aug 28 '18 at 13:37a,b,c,1234,23,Wembley London,267,agty
for the codeawk -F'"' -v OFS='' '{ for (i=2; i<=NF; i+=2) gsub(",", " ", $i) } 1' file
– Siva Aug 28 '18 at 13:54