Also, if you want to export internal json fields, use dot (. Operator).
JSON entry:
{ "_id" : "00118685076F2C77", "value" : { "userIds" : [ "u1" ], "deviceId" : "dev" }
mongoexport command with point operator (using mongo version 3.4.7):
./mongoexport --host localhost --db myDB --collection myColl --type = csv --out out.csv --fields value.deviceId, value.userIds
Csv output:
value.deviceId,value.userIds d1,"[""u1""]" d2,"[""u2""]"
Note. Make sure you are not exporting an array. This will damage the CSV format, for example, the field user identifiers shown above
Lokendra Chauhan Sep 09 '17 at 5:49 on 2017-09-09 05:49
source share