Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoexport --fields --csv will only output the first field when working with subdocuments

Working:

 .\mongoexport.exe --db mydb --collection slideproof_user_event_date_count --csv --out 
events.csv --fields '_id,first_day'
 .\mongoexport.exe --db mydb --collection slideproof_user_event_date_count --out 
events.json --fields '_id._p,first_day'

Not working (only first field/column has content) written, :

 .\mongoexport.exe --db mydb --collection slideproof_user_event_date_count --csv --out 
events.csv --fields '_id._p, first_day'

How can I enable correct output for .csv with subdocument fields?

like image 965
Cilvic Avatar asked Sep 22 '13 18:09

Cilvic


1 Answers

The solution is to avoid spaces in the --fields argument:

this works:

--fields '_id._p,value.count'

This does not:

--fields '_id._p, value.count'
like image 149
Cilvic Avatar answered Oct 21 '22 01:10

Cilvic