a)
$ vim export_to_cv.js
print("id,city")
cursor = db.media.find();
while (cursor.hasNext()) {
jsonObject = cursor.next();
print(jsonObject._id.valueOf() + "," + jsonObject.city)
}
b)
mongo mediadb export_to_cv.js
mongo [host]/[dbname] -u [username] -p [password] export_to_cv.js > output.csv
$ vim export_to_cv.js
print("id,city")
cursor = db.media.find();
while (cursor.hasNext()) {
jsonObject = cursor.next();
print(jsonObject._id.valueOf() + "," + jsonObject.city)
}
b)
mongo mediadb export_to_cv.js
mongo [host]/[dbname] -u [username] -p [password] export_to_cv.js > output.csv
No comments:
Post a Comment