Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Semi-Colon Delimiter in Mongoimport

Tags:

csv

mongodb

I have been trying to import several csv files into MongoDB using the Mongoimport tool. The thing is that despite what the name says in several countries the csv files are saved with semi-colons instead of commas making me unable to use the mongoimport tool properly.

There are some workarounds for this by changing the delimiter option in the region settings, however for several reasons I don't have access to the machine that generates this csv files so I can't do that.

I was wondering is there any way to import this csv files using the mongo tools instead of me having to write something to replace all the semi-colons on a file with commas? Since I find pretty strange mongo overlooking that in some countries semi-colons are used.

like image 697
user3323032 Avatar asked Mar 03 '14 17:03

user3323032


2 Answers

mongodb supports tsv then we should replace ";" by "\t" : tr ";" "\t" < file.csv | mongoimport --type tsv ...

like image 172
louisv Avatar answered Sep 29 '22 07:09

louisv


It looks like this is not supported,I can't find the option to specify a delimiter among the allowed arguments for 'mongoimport' on document page http://docs.mongodb.org/manual/reference/program/mongoimport/#bin.mongoimport . You can file a feature request on jira if it's something you'd like to see supported.

like image 42
Sumeet Kumar Yadav Avatar answered Sep 29 '22 07:09

Sumeet Kumar Yadav