Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda