Showing posts with label csv. Show all posts
Showing posts with label csv. Show all posts

Thursday, February 28, 2019

How to import csv data into mongodb?

How to import large amount of csv data to mongodb
mongoimport -d <dbname> -c <collection_name> --type csv --file </path/to/actual/file.csv> --headerline

<blah> - Replace with your respective values

-d <dbname> - Tells to your mongo server into which database you want to import
-c <collection_name> - Tells to your mongo server in <dbname> into which collection you want to import
--type csv - Says it is a csv file
--file <path> - Give full path to your csv file
--headerline - if given, uses the first line as field names.