質問

I am doing mongoimport with csv type and couldn't find an option to ignore commented lines. My csv has commented lines that are marked with "#" as the starting character. Basically, I am invoking MongoDB through a node.js app. No way to ignore these? Could someone suggest if there is an option?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top