1

When I export my MongoDB collection to a CSV, the String and Number "column" data types values are converted to "true" for 1 and "false" for 2 and null - how do I retain the values as numbers, strings and integers on export to CSV from Compass?

1 Answer 1

0

While I have not been able to completely eliminate the possibility of MongoDB Compass exporting 1's and "true" (bool) or 0's and "false" (bool) nor remove NaN in some "columns" with NULLs mixed with numbers, using "Int32" and "Int64" data types for non-decimal values reduces the number of "false bools", significantly in my MongoDB Compass exports (but not completely - enough to greatly reduce the number of manual/script changes).

The best workaround I have for these quirks of Compass is to switch to Robo 3T (Formerly known as Robomongo) which seems much more consistent and less "auto-magic" happening in the background. It's just a better tool for MongoDB all-around, IMPO.

Link: https://robomongo.org/download

Note: Download just the 'Robo 3T: "The Hobbyist GUI"' and not the Studio 3T package unless you want to spend money for it in a few weeks.

Robo 3T vs Compass

This is just one example of the MANY inconsistent behaviors I've observed while using Compass in Linux with a Gnome GUI instead of the mongoshell or Robo 3T on the same machine.

You can just use the mongoshell commands inside of Robo 3T to perform your CSV exports:

Example: mongoexport --db=PetHotel --collection=pets --type=csv -- fields=_id,name,type,weight --out=data/pets.csv

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.