Created
March 3, 2017 06:41
-
-
Save rjollet/1f62796ec1464e53965858dee23c24fd to your computer and use it in GitHub Desktop.
export tweet with text from mongo to csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mongo <host>/<dbname> -u <username> -p <password> export.js > out.csv | |
// mongo local --quiet export_text.js > tweets_text.csv | |
print("id\tlang\ttext"); | |
db.sample_stream.find({}, { 'tweet.id_str': 1, 'tweet.lang': 1,'tweet.text': 1, _id: 0}).forEach(function(doc){ | |
print(doc.tweet.id_str + "\t" + doc.tweet.lang + "\t" + doc.tweet.text.replace(/\t|\n|\r/g, ' ')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment