Quantcast
Channel: ReadyState4 » bash
Viewing all articles
Browse latest Browse all 4

Convert a file to utf8-encoding via command-line

$
0
0

I had an issue importing a large CSV to mongodb using mongoimport. I was getting the error:

exception:Invalid UTF8 character detected

Use iconv, a program that seems to be on both mac and most unix systems:

iconv -f ISO-8859-1 -t utf-8 accounts.csv > accounts-utf8.csv

Then continue on your merry way:

mongoimport --type csv --headerline --drop --port 7777  -d dbname -c collectionname --file accounts-utf8.csv

Viewing all articles
Browse latest Browse all 4

Trending Articles