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

mongimport of TSV/CSV file with Byte Order Mark causes incorrect field name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 3.2.8
    • Fix Version/s: None
    • Component/s: mongoimport
    • Labels:
      None
    • Environment:
      Customer found this on Windows. I reproduced it on OS X.

      Description

      Create a file in CSV or TSV format, with a header line, with a UTF-8 Byte Order Mark at the beginning (0xefbbbf). See such a file attached. mongoimport --type tsv --headerline on the file into a collection.

      Note that the first field's name in the database has a UTF-16 BOM in front of it. This is invisible during normal shell work, but it's there and prevents queries on that field from working. Here's a terminal session showing the issue.

      mongoimport --db test --collection foo --file jets_agency_systems.html --type tsv --headerline
      mongo
      MongoDB shell version: 3.2.8
      connecting to: test
      > db.foo.findOne()
      {
      	"_id" : ObjectId("57ab94a12486607096162845"),
      	"ID" : "C",
      	"AGENCY_TEXT" : "US AIR FORCE"
      }
      > db.foo.find({ID:'C'})
      > db.foo.find({"\ufeffID":'C'})
      { "_id" : ObjectId("57ab94a12486607096162845"), "ID" : "C", "AGENCY_TEXT" : "US AIR FORCE" }
      >
      

        Attachments

        1. jets_agency_systems.html
          0.9 kB
        2. working-issue.csv
          0.0 kB

          Issue Links

            Activity

              People

              Assignee:
              gabriel.russell Gabriel Russell (Inactive)
              Reporter:
              spencer.brown Spencer Brown
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: