Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
5 views
in Web Technology by (47.6k points)

How do you export all the records in a MongoDB collection to a .csv file?

mongoexport --host localhost --db dbname --collection name --type=csv > test.csv

This asks me to specify the name of the fields I need to export. Can I just export all the fields without specifying the names of fields?

1 Answer

0 votes
by (106k points)

To export collection to CSV in MongoDB you are not allowed spaces between comma separated field names.

The bad way is: -f firstname, lastname

The good way would be: -f firstname,lastname

Related questions

0 votes
1 answer
asked Sep 6, 2019 in SQL by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 24, 2019 in BI by Vaibhav Ameta (17.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...