saipriya
saipriya

Reputation: 11

How to import CSV file to MongoDB on Windows?

The mongoshell shows the result of the mongoimport command while trying to import a CSV file into MongoDB:

Image

I wanted to import a csv file into MongoDB. So I have used the command:

mongoimport -d dbname -c collectionname --type csv --file filename.csv --headerline

after executing this command I constantly got an error of missing ; before statement. I stored the file in the path mongo\bin only. Is the command itself wrong or should I save the file any other location than I have saved it now? Can anyone give a way to fix this command?

Upvotes: 1

Views: 8137

Answers (1)

ares
ares

Reputation: 4413

mongoimport is a binary that runs from OS shell and not the mongo shell.

So

C:\User\Home>mongoimport -d dbname -c collectionname --type csv --file filename.csv --headerline 

is correct while

mongo> mongoimport -d dbname -c collectionname --type csv --file filename.csv --headerline

is not.

Upvotes: 9

Related Questions