Skip to content

How to export the records in mongo to json or csv

YanLiang edited this page Mar 14, 2018 · 1 revision

when export to a csv, it requires a field list

mongoexport -h localhost --port ... --authenticationDatabase admin -u ... -p ... -d ... -c sourcedictionaries --fields _id,sentenceId,word,countryCode,firstRoleCode,secondRoleCode,confidenceFlag,userName,userId,dateStart,dateEnd,wikimongoid,taggingTime --csv --query "{'userName':'alze7746(wikicoding)'}" --out ~/zach-event.csv
mongoexport -h localhost --port ... --authenticationDatabase admin -u ... -p .... -d ... -c sourcedictionaries --query "{'userName':'alze7746(wikicoding)'}" --out ~/zach-event.json
Clone this wiki locally