Want to export MongoDB collection data to a csv file use mongoexport utility that produces data in JSON or CSV format.
Use the following command to export data:
mongoexport --host <hostName> --db <databaseName> --collection <collectionName> --csv --out nameOfFile.csv --fields Field1,Field2,Field3
Options:
- --host: Url of mongoDB
- --db: Name of Database
- --collection: Name of the Collection (Table)
- --csv: Download file in comma separated values (CSV) format. The default format is JSON.
- --out: Specify a file to write the export to
For example:
mongoexport --host localhost --db posts --collection blog --out dbFile.csv
0 Comment(s)