I have a CSV that was exported with double quotes around every header and value and I need them gone but without removing double quotes that might actually exist as values. For example:
"HEADER1","HEADER2","HEADER3","HEADER4","HEADER5"
"SOME_ID_0X0","SOME_ID_1X2","false","Some blob value with "double quotes" inside of it"
"SOME_ID_0X0","SOME_ID_1X2","false","Some blob value with "double quotes" inside of it"
"SOME_ID_0X0","SOME_ID_1X2","false","Some blob value with "double quotes" inside of it"
I can remove the first "
from every line with the following
$ sed -i.bak 's/^"//g' $1
And I can remove all the ones in between with this:
$ sed -i.bak 's/","/,/g' $1
And finally I thought I could remove the last "
in every line with this:
$ sed -i.bak 's/"$//g' $1
But it's not working. Could I accomplish this entire task in one line?
UPDATE I used this website to paste my data for hidden characters and here was the results
It appears some of the comment may be accurate but I don't know what that means I need to change still. Also is there a a clean way to check if the CSV has these quotes before attempting to remove them? Perhaps even just qualifying that the first character is a quote?
"
is not really the last character on each line (either because of trailing whitespace, or even because of DOS CRLF line endings)?dos2unix
??