Having trouble with Mongoimport - mongodb

trying to import a csv file into my MongodbAtlas collection.
This is the command I run in terminal:
mongoimport --uri mongodb+srv://Jfreundlich01:<PASSWORD>#seir-cluster.sclij.mongodb.net/Optimizer --collection Players --type csv --file "Seed.csv"
Where Seed.csv is a file on my desktop.
When I click return it goes to a new line in my terminal but nothing happens.
After I run that line, if I type mongoimport --help or --version or any of those options, I get:
no such file or directory: <part of my password>#seir-cluster.sclij.mongodb.net/Optimizer
But if I close the terminal, open a new terminal and run mongoimport --version i get:
mongoimport version: 100.6.0
Any help/guidance would be greatly appreciated!
Thanks

Related

Can I run mongoimport as a part of Jenkins build step

I am running a job which produces a json output file and I want to dump the file contents into mongo as a part of build step but when I run mongoimport the job fails saying mongoimport command not found
Below is the command am using as a part of build step shell script:
'''mongoimport --uri "dbString" --drop --collection col-name --file file-path-in-workspace -- jsonArray'''

Problems with MongoDB csv upload

I'm trying to import a csv file into MongoDB and running into "Unexpected Identifier" error.
mongoimport –-db projectexperiment -—collection structured_1000 --type csv --file /dataset/structured/structured_1000.csv --headerline
Am quite new to MongoDB and was wondering if some one could point me in the right direction
You need to run mongoimport from the terminal. Assuming you are using Windows, you need to start a DOS prompt (cmd) go to the bin directory of your mongodb installation and run your monogimport command:
C:\mongodb\bin>mongoimport –-db projectexperiment -—collection structured_1000 --type csv --file /dataset/structured/structured_1000.csv --headerline

Error in importing a csv file in mongoDB2.4

I have installed mongoDB2.4 installed in my windows 7 os. I am new to mongoDB. I would like to import data from a csv file into the database. I have used the mongoimport command but it shows:
Javascript execution failed: Syntax error: Unexpected identifier
my command in mongo shell was:
mongoimport --db mentalhealth --collection bidyut --type csv --file \Users\Adrian\Desktop\Data_sorted.csv
PLEASE kindly provide an answer.

how to import csv file in mongodb

I have a csv file containing following data and want to import it in mongodb
ID;"AdmissionID";"SeatNo";"RegistrationNo";"ResultDate";"ResultStatusId"
1;12;"2323";"23";07-05-2013;1
2;23;"35";"32";10-05-2013;5
this data is to be imported to mongodb 2.2. I'm using following command:
mongoimport -d test -c exam --type csv --headerline <f:\exam.csv
when used i get following error
SyntaxError: missing ; before statement (shell):1
please help me to find out the error
This should do the trick easily. More HERE.
mongoimport -d mydb -c collectionName --type csv --file myfile.csv --headerline
Your problem is the <f:\exam.csv bit, which is not properly escaped by the way it looks
> --headerline
> If using “--type csv” or “--type tsv,” use the first line as field names. Otherwise, mongoimport will import the first line as a distinct
> document.
Please try this line of code
C:\Program Files\MongoDB\Server\3.2\bin>mongoimport -d pravin -c FOC --type csv
--file D:\Script\ImportData\FOC.csv --headerline
2016-08-10T15:42:38.685+0530 connected to: localhost`enter code here`
2016-08-10T15:42:38.758+0530 imported 13 documents
I solved by opening the .csv file in Excel (File -> Options -> advanced) then unchecking the box "uses system separation" and then removing the comma from the box below and then saving again in .csv.
So there will not be any commas in the .csv file and the formatting of JSON in MongoDB will be right.
Run mongoimport from the system command line, not the mongo shell.
Ref - https://docs.mongodb.com/manual/reference/program/mongoimport/

Cannot import mongodb

I tried mongo import like this
mongoimport -d test -c foo importfile.json
mongoimport --host localhost --db local --collection lecturer --type json --file temp.json --headerline --upsert
and I've got same error message "Syntax Error: missing ; before statement (shell):1"
what's wrong with my code & how to import if my data stored in C:\Documents and Settings\User\Desktop ?? please help, thank's in advance
mongoimport is intended to run in command prompt and not in the mongo shell. Try exiting out of the shell and running the command.
One solution is:
First, in cmd, change to the directory containing mongoexport.exe file, then type your command.
C:\Program Files\MongoDB\Server\3.2\bin> .\mongoexport.exe -d foo -c bar -o output.json
mongoimport is to be run on the terminal and not inside the mongo shell. To run mongoimport in terminal, you will need to install the same. On ubuntu, you can do :
apt-get install mongo-tools
Hope this helps :)
I had the same problem and was able to figure it out after a brief struggling and googling.
1. Navigate to the bin directory in command prompt
(cd c:..\bin)
2. Run the mongoimport command but you have to specify the full path of your json file.
That solves the problem
try to use CSV is a good.
mongoimport -d mydb -c things --type csv --file locations.csv --headerline --upsert
You can convert by ms excel.
Open the "Mongo/Server/3.4/bin" folder of mongo db in another command window and try again.It Will work.
Open a new terminal or command prompt within the location of the file you want to import and it should work. It will not work on MongoDB shell