Mongoexport - doesn't export exact _id as per collection

Hi, when I export csv using mongoexport that _id filed doesn’t export as per collection. The format gets change in csv. I would like to export _id filed which is available in collection. for an example:
In my collection I am having “_id” : UUID(“0005baaf-eea9-4b9d-b13e-59e238e804ec”)

When I export in csv it is exporting like 0005BAAFEEA94B9DB13E59E238E804EC.

mongoexport /db dbname /collection collectionname /type csv /fields _id /out test11.csv

I would like to export exactly like UUID(“0005baaf-eea9-4b9d-b13e-59e238e804ec”) in CSV.

Hi Yatin,

I believe the export is correct, since it exported the content of the UUID field. UUID() is a function in the mongo shell that can generate a random UUID for you, and it also signifies that the content of a field is a proper UUID as defined in RFC4122. This is similar to ObjectId() in the shell, or ISODate().

In fact, some may argue that exporting the field by enclosing it in UUID(...) is the wrong thing to do, since anything with brackets typically signifies a function call. It is also was not mentioned that a UUID should be enclosed in a function-call-like format as per RFC4122.

If you would like to export the field enclosed in UUID(...) then unfortunately you would have to roll out your own post-export processing.

Best regards,

Thanks ! I will do the same.