Trying to import a CSV with contact information:
Name,Address,City,State,ZIP
Jane Doe,123 Main St,Whereverville,CA,90210
John Doe,555 Broadway Ave,New York,NY,10010
Running this doesn't seem to add any documents to the database:
$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline
Trace says imported 1 objects
, but firing up the Mongo shell and running db.things.find()
doesn't show any new documents.
What am I missing?
Robert Stewart have already answered for how to import with mongoimport.
I am suggesting easy way to import CSV elegantly with 3T MongoChef Tool (3.2+ version). Might help someone in future.
See how to import video
C:\wamp\mongodb\bin>mongoexport --db proj_mmm --collection offerings --csv --fieldFile offerings_fields.txt --out offerings.csv
Just use this after executing mongoimport
It will return number of objects imported
will return the number of objects.
For the 3.4 version, please use the following syntax:
After 3 days, I finally made it on my own. Thanks to all the users who supported me.