1
 mongoimport -d  ramp -c country --type csv --file http://fromtheramp.com/temp/country.csv --headerline

I had use import funtionality on localhost and is working fine. but now, it is not working on server. it gives me the following error.

Failed: open http://fromtheramp.com/temp/country.csv: no such file or directory

http://fromtheramp.com/temp/country.csv file exists but is not getting imported.

1 Answer 1

2

The mongoimport utility does not work with external file sources such as a URI resource like you are trying to do.

In order to do what you want, "pipe" the input from another command like curl to mongoimport instead:

curl http://fromtheramp.com/temp/country.csv | \
mongoimport -d  ramp -c country --type csv --headerline

Both mongoimport and mongoexport both work with STDIN/STDOUT as default unless you include an option such as --file. So omit that and work with STDIN instead.

As a non-csv example ( same principles apply though ) you can use the publicly accessible mongodb sample data set as a test:

curl https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/dataset.json | \
mongoimport -d test -c restaurants --drop

Which hapilly imports that data, and a bit more effienctly than the manual page suggests you do it. Though you might want a local copy for testing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.