mongoimport CSV with pymongo

我的梦境 提交于 2019-12-23 06:26:46

问题


I found a command for mongodb which lets you import CSV files as a whole: https://docs.mongodb.com/manual/reference/program/mongoimport/

like this:

mongoimport --db users --type csv --headerline --file /opt/backups/contacts.csv

However, there seems to be no mention of this in Pymongo. Does it exists, and if so what is the syntax for it? Thanks in advance


回答1:


mongoimport is a command-line program that you install. Instructions for installing MongoDB, including its tools like mongoimport, are here:

https://docs.mongodb.com/manual/administration/install-community/

Once you've done that, execute mongoimport from the Unix shell or Windows command prompt, whichever system you're on.

PyMongo is a Python driver for MongoDB, it allows you to write Python code that executes queries and commands on MongoDB over the network. PyMongo is separate from the MongoDB tools like mongoimport.



来源:https://stackoverflow.com/questions/43999171/mongoimport-csv-with-pymongo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!