Skip to content

Instantly share code, notes, and snippets.

@rjollet
Created February 8, 2017 05:48
Show Gist options
  • Save rjollet/21f98f4659c8190eeed4b2c6a8b468fb to your computer and use it in GitHub Desktop.
Save rjollet/21f98f4659c8190eeed4b2c6a8b468fb to your computer and use it in GitHub Desktop.
export mongo to csv file
// mongo <host>/<dbname> -u <username> -p <password> export.js > out.csv
// mongo local --quiet export.js > out.csv
print("id, in_reply_to_status_id, user_id");
db.sample_stream.find({}, { 'tweet.id_str': 1, 'tweet.in_reply_to_status_id_str': 1 , 'tweet.user.id_str': 1, _id: 0}).forEach(function(doc){
print(doc.tweet.id_str + "," + doc.tweet.in_reply_to_status_id_str + "," + doc.tweet.user.id_str);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment