How to remove the double quotes in a CSV file on Ubuntu

This post introduces the simplest way to remove all double quotes in a csv file on Ubuntu (via terminal).

If you have a CSV file like

#input.csv
"1,2,3,4,9"
"1,2,3,6,24"
"1,2,6,8,28"
"1,2,4,6,30"

and want something like

#output.csv
1,2,3,4,9
1,2,3,6,24
1,2,6,8,28
1,2,4,6,30

Or you have something like this

and want something like this

In your terminal,

cd to the directory where input.csv file is located and then issue the following command:

$ tr -d '"' <input.csv> output.csv

Note: tr stands for translateThe d flag causes tr command to delete all tokens of the specified set of characters from its input.  

References:

8 Linux TR Command Examples (pdf)

tr (Unix)

Leave a Reply

Your email address will not be published. Required fields are marked *