Exporting from mongo to csv with respect to a field on a large collection.

30 views
Skip to first unread message

Leninlal K

unread,
Aug 17, 2016, 3:47:47 PM8/17/16
to mongodb-user
Hi everyone,
i've added large amount of  data to mongo , currently it has 70 million data and i wanted to export it to csv with respect to a field.

(ie) sample data : {'name' : 'name1', 'age': age1 , 'location' : 'location1'}

currently i've 10000 distinct locations , i want to split the data into multiple files based on location.

right now i'm using mongoexport with query from a python script, does this problem have a mongo specific solution ????

Thanks

William Hagan

unread,
Aug 18, 2016, 2:36:10 PM8/18/16
to mongodb-user
Hello,

You can make use of the "query" option in the mongoexport tool.

E.g. mongoexport --host=<host_server> --port=<host_port> --db=<database_name> --collection=<collection_name> --query='{"location" : "location1"}' --out=<location1_csv_file> --type='csv'

I hope that helps?

Cheers
Reply all
Reply to author
Forward
0 new messages