Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-1218

mongoimport --fields definition is wrong

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • mongodb-2.4
    • v1.2
    • manual
    • None

    Description

      http://docs.mongodb.org/manual/reference/mongoimport/#cmdoption-mongoimport--fields

      It is actually the names of the fields which are used when importing a csv/tsv files, just like if the first line of the data file was a header with the field names (it is for when you have no header line).

      For example, if you're csv file looks like this:

      ObjectID(5129532ad3f16b57ad27c1a8),1.0
      ObjectID(513ceccbdde3c92b2241d259),

      And you want your imported docs to look like:

      { "_id" : "ObjectID(5129532ad3f16b57ad27c1a8)", "a" : 1 }
      { "_id" : "ObjectID(513ceccbdde3c92b2241d259)" }

      You would import like this:

      mongoimport -c col -d test --type csv --fields _id,a  /tmp/col.csv 

      Attachments

        Activity

          People

            sam.kleinman Sam Kleinman (Inactive)
            dan@mongodb.com Daniel Pasette (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10 years, 49 weeks, 1 day ago