etldev
November 26, 2014, 1:58pm
1
I have a csv file which is produced out of a SED command
sed 's/|/","/g; s/^/"/; s/$/"/' A4.txt > A5.csv
and I need either an addition to the SED command or a separate command to convert the following characters which occur within the fields in multiple lines
1)
"="
to
="
and
2)
""~
to
"
RudiC
November 26, 2014, 2:11pm
2
What stops you from adding the respective substitute commands
sed 's/"="/="/g;s/""~/"/g' file
to your above sed script?
And, a sample input file would be nice...
etldev
November 26, 2014, 9:03pm
4
can I combine everything as ??
sed 's/|/","/g; s/^/"/; s/$/"/; 's/"="/="/g; s/""~/"/g' A4.txt > A5.csv
otheus
November 27, 2014, 11:09am
6
Yeah you combine but only ONE pair of SINGLE-QUOTE marks (')....
sed 's/|/","/g; s/^/"/; s/$/"/; s/"="/="/g; s/""~/"/g' A4.txt > A5.csv
Also, to prevent double quotes at the beginning and end of lines, you can add:
sed 's/|/","/g; s/^"*/"/; s/"*$/"/; s/"="/="/g; s/""~/"/g' A4.txt > A5.csv
So if a line already begins (or ends) with double- (or tripple-) quotes, it replaces them with one double-quote character.