Mongodb – Importing a large tsv file to mongodb

mongodb

I'm trying to import a large one giga tsv file names bouffe.csv. It is in ̀ mongo.../bin but seems there is a syntax error :

> ./mongoimport -d db_name -c collection_name --type tsv --file bouffe.csv -f --numInsertionWorkers 8 --headerline

2017-12-05T22:11:01.064+0100 E QUERY    [thread1] SyntaxError: expected expression, got '.' @(shell):1:0

I am not able to handle it, I am quite new to this database system.

Here is an overview :

enter image description here

Best Answer

@Marine1,You mongoimport syntax should be like as mention below example.

mongoimport --db test --collection stuff --type csv C:\data\Employee.csv --headerline

In the above example test is database name, stuff is collection name and Employee.csv is the file which i want to import in MongoDB database through mongo shell. And the Employee.csv file location is C:\data\Employee.csv. In My case it has worked properly.

In your case the syntax should be like that

mongoimport --db databasename --collection collectionname --type csv  locationofbouffe.csv  --headerline

The syntax should be in the above mention format, if you want to import the header of the file then mention --headerline.

Note:- Make sure you are running the above mention script in inside the BIN of MongoDB Server.

Very Important Note : mongoimport would be to import a non-BSON file (such as JSON or CSV) into mongodb.