Niko
Niko

Reputation: 111

mongoimport CSV with pymongo

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

Upvotes: 1

Views: 3381

Answers (1)

A. Jesse Jiryu Davis
A. Jesse Jiryu Davis

Reputation: 24007

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.

Upvotes: 1

Related Questions