我正在使用 csv 类型执行 mongoimport,但找不到忽略注释行的选项。我的 csv 已经注释了标有“#”作为起始字符的行。基本上,我通过 node.js 应用程序调用 MongoDB。没有办法忽略这些吗?有人可以建议是否有选择?
问问题
656 次
1 回答
2
CSV (Comma Separated Values) format is intentionally simple and does not have support for comments. You'll have to pre-filter your commented lines before passing through to mongoimport
.
mongoimport
is intended to be used from a command-line, but you've mentioned you are talking to MongoDB from a Node.js app.
Rather than invoking mongoimport
, I would recommend using a node.js csv module. You can then easily do your own line-based filtering for comments or other format deviations, and insert using the MongoDB driver directly.
于 2013-03-01T13:08:58.313 回答