tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 No SQL > Mongo DB > How to import database collection from CSV or JSON

How to import database collection from CSV or JSON 

MongoDB is a scalable, high-performance, open source NoSQL database. It offers Ad hoc queries, Indexing, Replication, Load balancing, File storage (GridFS), Aggregation, MapReduce and Server-side JavaScript execution. A single mongod process runs on one machine, and can host many databases. Each database can have many Collections (Can say "tables" in RDBMS language). The following example shows how to import a Collection using mongoimport utility.

mongoimport -d yourdb -c zipcodes "C:\VENKAT\DOWNLOADS\MONGO_DB\zips.json"
mongoimport -d yourdb -c companies --type csv 
	--file "C:\VENKAT\DOWNLOADS\YAHOO_STOCKS\HISTORY\companylist.csv" --headerline


	-d [ --db ] arg             The database to use
	-c [ --collection ] arg     The Collection to use
	--type arg                  Type of file to import.  default: json (json,csv,tsv)
	--headerline                CSV,TSV only - use first line as headers
	--file arg                  File to import from; if not specified stdin is used
Importing content from JSON file, export2.gif Importing content from CSV file, export2.gif


bl  br