2

I want to export collection in mongodb using shell command: I try the following command but fields with ":" (number:phone, number:fax) are not exported.

mongoexport --csv -d schemaName -c collectionName -q "{typeName:'user'}" -f "name, surname, e-mail, number:phone, number:fax" -o export.csv
4
  • Can you post an example of the document that you're trying to export? Commented Jul 31, 2012 at 14:33
  • This is the example document. {'path': '/users/sarahperez', 'name':'Sarah', 'surname':'Perez', 'e-mail':'[email protected]','number:phone':'00421236523','number:fax':'004215377853'} {'path': '/users/ericeldon', 'name':'Eric', 'surname':'Eldon', 'e-mail':'[email protected]','number:phone':'00421276823','number:fax':'0042165928725'} @Jenna Commented Jul 31, 2012 at 14:38
  • Hmm, I think the issue may have to do with the fact that the field name has a colon in it. I can export the fields of an embedded document such as {number: {fax: 123, cell: 345}} using the dot notation. I'll keep investigating. Commented Jul 31, 2012 at 14:52
  • you can export it okay as JSON just not CSV Commented Jul 31, 2012 at 16:58

1 Answer 1

2

I think that you have found a legitimate bug. The mongoexport tool is rarely used and the colon means something very specific when parsing JSON, so the tool is probably confused.

You can file the bug here: http://jira.mongodb.org/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.