Pratha Saxena
Pratha Saxena

Reputation: 1

How do I merge csv to a collection using mongoimport

I'm trying to import a csv to my mongodb collection using the command

mongoimport --mode merge --headerline --upsertFields firstname --db Intelligense --collection demo --file demo.csv --type csv

but getting

error inserting documents: An empty update path is not valid.

What am I doing wrong?

I have a collection "demo" under database "Intelligense" with has data in the format

{ 
    "_id" : ObjectId("5cd8559c041f762929f36d97"), 
    "firstname" : "john", 
    "lastName" : "mayer"
}

and my csv contains

_id, email, firstname 5cd8559c041f762929f36d97,[email protected], john

I want to achieve the following collection as end result

{ 
    "_id" : ObjectId("5cd8559c041f762929f36d97"), 
    "firstname" : "john", 
    "lastName" : "mayer",
    "email" : [email protected]
}

Upvotes: 0

Views: 575

Answers (1)

Pratha Saxena
Pratha Saxena

Reputation: 1

I found the answer. The problem was the index column without header in my csv file which was invalid.

Upvotes: 0

Related Questions