mongoDB – import a CSV file in a database collection

Suppose if you have a CSV file with large number of records and you want to import it into  database collection then need to use


mongoimport --db users --collection contacts --type csv --headerline --file contacts.csv

will specify database,


will represent contacts collection


is representing that  CSV file


is representing the top line in file is header or column names.


is path to file to import

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.