如何将mongoDB数据导出为CSV格式? [英] How to export mongoDB data into a CSV format?
问题描述
我正在寻找一种非常简单的方式将数据从mongoDB导出到CSV。大多数答案涉及bash脚本和hellip;有没有简单的mongoDB命令只是将数据导出到CSV?
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?
推荐答案
这可以从命令行使用mongo 效用函数 mongoexport - -csv
。
This can be done from the command line using the mongo utility function mongoexport --csv
.
除了 - csv
您还需要使用 - 字段
或指定包含使用 - fieldFile
。
Alongside the --csv
the documentation states that you also need to use --fields
or specify a file with the fields in using --fieldFile
.
http://docs.mongodb.org/manual/reference/program/mongoexport/#usage =noreferrer> 使用示例 ,看看他们是否有帮助,例如:
Have a look at the usage examples and see if they help, for example:
mongoexport --db users --collection contacts --csv --fieldFile fields.txt
这篇关于如何将mongoDB数据导出为CSV格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!