How can one change the file encoding from linux (Fedora 20) command line? I have a huge CSV file 7GB and I don't wish to open it.
1 Answer
- open a console window or terminal...
- to find out the current encoding
file -bi /path/to/file.csv
the result should look something like
"text/plain; charset=us-ascii"
- now for the conversion:
iconv -f inputEncoding -t outputEncoding /path/to/input/file.txt -o path/to/output/file.txt
for example:
iconv -f iso-8859-1 -t utf8 ~/Documents/bigger_not_filtered.csv -o /tmp/utf8_bigger_not_filtered.csv
3 Comments
deceze
Note that
file can only give you a best guess for the encoding. You should know what your files are encoded in based on some specification or meta data. If you don't and you need charset detection, you need to employ heuristics, or human eyeballing.Marcel Pfeiffer
You have to set the output file with the
-o argument.Kiara Grouwstra
thanks @MarcelPfeiffer, i updated the answer.