I am using Mongo Version 2.6.12 on CestOS6.7. It is non-clustered ie installed only on one server.
My project requires final output to be stored in MongoDB. The files are CSVs stored on Linux and HDFS. Can someone please guide me how to import CSV files into mongo DB from Linux/HDFS.
Mongoimport does not work as it takes by default input as JSON files. I tried this in mongo-shell, it failed
mongoimport news-output-20170125.csv --type csv
2017-01-30T19:18:25.275-0600 SyntaxError: Unexpected identifier
Mongoimport from Linux is working for CSV file now. I was running mongoimport from mongo-shell. hence was getting the error.
[mongoritter@**** ~]$ cat locations.csv
Name,Address,City,State,ZIP
Jane Doe,123 Main St,Whereverville,CA,90210
John Doe,555 Broadway Ave,New York,NY,10010
[mongoritter@**** ~]$ pwd
/home/mongoritter
[mongoritter@**** ~]$ mongoimport -d test -c test1 --type csv --file locations.csv –headerline
connected to: 127.0.0.1
2017-01-31T12:12:22.034-0600 imported 2 objects
for more help, you can refer How to use mongoimport to import csv
Now, I will check way for import from HDFS. I have seen a mongo document, will check if this works or not https://www.mongodb.com/blog/post/using-mongodb-hadoop-spark-part-1-introduction-setup
Thanks, SHilpa
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.