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

mongoimport tab-delimited files retains quotes and ignores escaped tabs

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: mongoimport
    • None
    • Environment:
      CentOS 5.5

      It seems to me that tab-delimited fields should operate the same as comma-delimited fields, where begin and end quotes are ignored, and escaped tabs or tabs embedded within double quotes are retained correctly.

      $ cat blah.tsv
      1<tab>"This sentence is quoted"
      2<tab>This sentence\<tab>has a tab in it
      3<tab>"So does this<tab>sentence"

      $ mongoimport --db blah -c blah --file blah.tsv --fields a,b --type tsv --drop -vvv
      Mon Feb 21 22:47:05 creating new connection to:127.0.0.1
      connected to: 127.0.0.1
      Mon Feb 21 22:47:05 ns: blah.blah
      dropping: blah.blah
      Mon Feb 21 22:47:05 filesize: 87
      Mon Feb 21 22:47:05 got line:1 "This sentence is quoted"
      Mon Feb 21 22:47:05 got line:2 This sentence\ has a tab in it
      Mon Feb 21 22:47:05 got line:3 "So does this sentence"
      Mon Feb 21 22:47:05 got line:
      imported 3 objects

      $ mongo blah
      MongoDB shell version: 1.6.5
      connecting to: blah
      > db.blah.find()

      { "_id" : ObjectId("4d62eb6b76a8a7bc009e7846"), "a" : 1, "b" : "\"This sentence is quoted\"" } { "_id" : ObjectId("4d62eb6b76a8a7bc009e7847"), "a" : 2, "b" : "This sentence\\", "field2" : "has a tab in it" } { "_id" : ObjectId("4d62eb6b76a8a7bc009e7848"), "a" : 3, "b" : "\"So does this", "field2" : "sentence\"" }

            Assignee:
            backlog-server-platform DO NOT USE - Backlog - Platform Team
            Reporter:
            ian@mongodb.com Ian Whalen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: