2015-08-24 163 views
0
mongoimport -d ramp -c country --type csv --file http://fromtheramp.com/temp/country.csv --headerline 

我在本地主機上使用導入功能,工作正常。但現在,它不在服務器上工作。 它給了我以下錯誤。Mongodb CSV功能不能正常工作

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

http://fromtheramp.com/temp/country.csv文件存在但未獲取導入。

回答

1

mongoimport實用程序無法與外部文件源一起使用,例如您嘗試執行的URI資源。

爲了做到你想要什麼,「管」,從另一個命令像curlmongoimport不是輸入:

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

兩個mongoimportmongoexport與標準輸入/輸出都作爲缺省值,除非你有一個選項如--file。所以省略它,並用STDIN代替。

作爲一個非CSV範例(同樣的原則雖然適用),則可以使用公開訪問MongoDB的樣本數據集作爲一個測試:

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

這hapilly進口數據,以及更effienctly比了一下manual page建議你這樣做。儘管您可能需要本地副本進行測試。

+0

謝謝。你讓我今天一整天都感覺很好。 –