Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-1418

Avoid scientific notation in export of large doubles

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.4.0
    • Affects Version/s: 3.2.8
    • Component/s: mongoexport
    • Environment:
      OS X El Capitan
      MongoDB v3.2.8 (via macports)
    • Platforms 2017-01-23
    • Needed
    • v3.2, v3.0

      I have been trying to export data to CSV with integer ID values that are stored as doubles.

      Unfortunately, the larger numbers are exported in scientific notation, which means that either the ID is no longer accurate due to a decrease in significant digits, or that the target DB cannot interpret the numbers as it cannot parse scientific notation.

      It would be very useful to have one of two options:

      1) Something like a --toString option that simply converts all values to strings. They are typically not surrounded by quotations, so can easily be interpreted in any manner by another tool.

      2) An equivalent to the --fieldFile option where the data format can be specified.

      Currently I have to run scripts that do something like:

      db.collection.find().forEach(function(item)

      { item.clientID = '' + item.clientID db.tmpcollection.insert(item) }

      )

      and then export the temporary collection.

      If implemented, there would need to be changes to the documentation for mongoexport describing the solution.

            Assignee:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Reporter:
            Bullitt Frank Ortmann [X]
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: