Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-682

mongoimport in csv mode/type seems to have problems with whitespaces in column values

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.3.3
    • Affects Version/s: 1.2.1
    • Component/s: Tools
    • Labels:
      None
    • Environment:
      Mac OSX 10.6.2, MongoDB installed via Macport

      When given a csv file (att: recordshelf-genres.csv) and imported via 'mongoimport -d recordshelf -c genres --file recordshelf-genres.csv --drop -f name --type csv --headerline --ignoreBlanks' the imported collection looks (is) incorrect possible due to whitespace issues in the column value 'Drum and Bass'. See next snippet from mongo shell showing the corrupted data.

      db.genres.find()

      { "_id" : ObjectId("4b886702982b57076c82e282"), "name" : "Drum and Bass" } { "_id" : ObjectId("4b886702982b57076c82e283"), "name" : "Rap", "field1" : "and Bass\"" } { "_id" : ObjectId("4b886702982b57076c82e284"), "name" : "House", "field1" : "d Bass\"" } { "_id" : ObjectId("4b886702982b57076c82e285"), "name" : "Reggae", "field1" : "Bass\"" } { "_id" : ObjectId("4b886702982b57076c82e286"), "name" : "Dubstep", "field1" : "Bass\"" }

      When column value 'Drum and Bass' get replaced (att: recordshelf-genres-jazzed.csv) with e.g. Jazz the csv mongoimport (same call as above with modified import csv) works as expected as shown in the next mongo shell excerpt.

      db.genres.find()

      { "_id" : ObjectId("4b886860982b57076c82e287"), "name" : "Jazz" } { "_id" : ObjectId("4b886860982b57076c82e288"), "name" : "Rap" } { "_id" : ObjectId("4b886860982b57076c82e289"), "name" : "House" } { "_id" : ObjectId("4b886860982b57076c82e28a"), "name" : "Reggae" } { "_id" : ObjectId("4b886860982b57076c82e28b"), "name" : "Dubstep" }

      Looks like a bug to me, but maybe I'm just to tired for seeing a trivial solution for this issue or I'm issuing mongoimport in a false way. If that's the case sorry for opening this issue ;D

        1. recordshelf-genres.csv
          0.1 kB
        2. recordshelf-genres-jazzed.csv
          0.0 kB

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            raphaelstolt Raphael Stolt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: