How to define delimeter to import mongodb

Shashika picture Shashika · Nov 25, 2013 · Viewed 11.5k times · Source

I have a data collection, which is separated by | character. I am going to add the data collection to mongodb. So I need to separate data through | character. how my mongoimport command looks like?

Previously, I'm successfully import csv file through the following command.

$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline

Answer

Derick picture Derick · Nov 25, 2013

mongoimport supports either JSON, CSV (comma separated values) or TSV (tab separated values). The | character is not a valid delimiter for either CSV or TSV, so you will need to change your input files' | to , or a tab, and specify --type accordingly.