No SQL > Mongo DB > How to export database collection to CSV or JSON file
How to export database collection to CSV or JSON file
MongoDB is a scalable, high-performance, open source NoSQL database.
It offers Ad hoc queries, Indexing, Replication, Load balancing, File storage (GridFS), Aggregation,
Each database can have many Collections (Can say "tables" in RDBMS language).
The following example shows how to export a Collection using mongoexport utility.
mongoexport -d mytestdb -c students -o students.json
mongoexport -d mytestdb -c students -f name,age -o students2.json
mongoexport -d mytestdb -c students -f name,age --csv -o students.csv
-d [ --db ] arg The database to use
-c [ --collection ] arg The Collection to export
-f [ --fields ] arg Comma separated list of fields to export
-o [ --out ] arg Output file to export Content; if not specified, stdout is used
--csv Exports the contents of Collection as CSV instead of JSON.