Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using mongoexport to export some collections into CSV files, however when I try to target fields which are members of an array I cannot get it to export correctly.

command I'm using:

mongoexport -d db -c collection -fieldFile fields.txt --csv > out.csv

and the contents of fields.txt is similar to

id
name
address[0].line1
address[0].line2
address[0].city
address[0].country
address[0].postcode

where the BSON data would be:

{
    "id": 1,
    "name": "example",
    "address": [
        {
            "line1": "flat 123",
            "line2": "123 Fake St.",
            "city": "London",
            "country": "England",
            "postcode": "N1 1AA"
        }
    ]
}

what is the correct syntax for exporting the contents of an array?

share|improve this question

fields should be

id
name
address.0.line1
address.0.line2
address.0.city
address.0.country
address.0.postcode
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .