Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
upserting mongoDB collection with CSV file

i have one mongoDB collection which have follwing value

        lat    long   band1
       23.454  56.454  67

i want to updated that collection so that i get follwing collection

      lat     long    band1  band2
      23.454  56.454  67      73

csv which i want to use for update is contains

  34.656,87.7565 ,78

size of this csv is 5gb

I'm using follwing commands to updated collection

 mongoimport --db test --collection nct_test --upsert --upsertFields band2 --file gdalexportedb8.csv

but I'm getting follwing error..

    Failed: error processing document #2: invalid character ',' looking for beginning of value

I want to know this is the right way or not and can anybody help me in this..

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Regarding to your CSV file

  • Add a new line at the beginning containing field names.

Regarding to your command

  • Add these to your command: --type csv--headerline

for example:

$ cat > locations.csv
Name,Address,City,State,ZIP
Jane Doe,123 Main St,Whereverville,CA,90210
John Doe,555 Broadway Ave,New York,NY,10010
 ctrl-d
$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline
connected to: 127.0.0.1
imported 3 objects
$ mongo
MongoDB shell version: 1.7.3
connecting to: test
> use mydb
switched to db mydb
> db.things.find()
{ "_id" : ObjectId("4d32a36ed63d057130c08fca"), "Name" : "Jane Doe", "Address" : "123 Main St", "City" : "Whereverville", "State" : "CA", "ZIP" : 90210 }
{ "_id" : ObjectId("4d32a36ed63d057130c08fcb"), "Name" : "John Doe", "Address" : "555 Broadway Ave", "City" : "New York", "State" : "NY", "ZIP" : 10010 }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!