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

data && datatype have benn changed by mongoimport

    • Type: Icon: Question Question
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.2.8
    • Component/s: mongoimport
    • Labels:
      None
    • Environment:
      RHEL6.5
    • v2.6

      Hello Mongo!!
      while I use mongoimport to insert data , I found that some data's type have been changed automatically.

      the string "0004" --changed to------> INT 4

      questions:
      1.is there some mechanism of mongodb cause this?
      2.do we have some action plan to avoid this happen?
      since my original data is a string,which represent someone's ID
      the changes totally destory change our data

      [mongo@mongos3 ~]$ cat MONGO.csv
      "ID","DAY"
      "0004","2016-08-24 10:55:44"
      "1004","2016-08-24 11:50:28"

      MongoDB Enterprise mongos> db.mongo.find().forEach(function{if({"ID":{$type:16}}){count++}});
      print(count);
      MongoDB Enterprise mongos> print(count);
      2

      MongoDB Enterprise mongos> db.mongo.find().pretty()

      { "_id" : ObjectId("57bd4687ff3116d554692267"), "ID" : 4, "DAY" : "2016-08-24 10:55:44" } { "_id" : ObjectId("57bd4687ff3116d554692268"), "ID" : 1004, "DAY" : "2016-08-24 11:50:28" }

            Assignee:
            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            Reporter:
            fengjing@vastdata.com.cn Jing Feng
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: