I'm looking for a very simple way to export data from mongoDB into a CSV. Most of the answers involve bash scripts… etc. Is there a simple mongoDB command that will just export the data into CSV?
相关问题
- MongoDB can not create unique sparse index (duplic
- sqlyog export query result as csv
- Spring Data MongoDB - lazy access to some fields
- Excel sunburst chart: Some labels missing
- Golang mongodb aggregation
相关文章
- mongodb有没有什么办法禁止读取数据的时候进行缓存
- mongodb-aggregate聚合查询分组后如何获得多字段
- mongodb error: how do I make sure that your journa
- How to track MongoDB requests from a console appli
- How to read local csv file in client side javascri
- Get column data by Column name and sheet name
- programmatically excel cells to be auto fit width
- MongoError: cannot infer query fields to set, path
Update:
As of mongo 3.0.6
--csv
is no longer supported and the new flag is--type=csv
, so the command would bemongoexport --db users --collection contacts --type=csv --fieldFile fields.txt
Original answer:
This can be done from the command line using the mongo utility function
mongoexport --csv
.Alongside the
--csv
the documentation states that you also need to use--fields
or specify a file with the fields in using--fieldFile
.Have a look at the usage examples and see if they help, for example:
If you already have the .bson file, in order to export to csv:
It's pretty easy with mongoDB compass, you just need to goto
Collection -> Export Collection -> Select Export data as JSON or CSV
and export the data.