I was hoping that I could just $set using "row" as it contains all the data I would want to update but get the following. My code is below:
c:\mongo scripts>csvimporter.py Traceback (most recent call last): .... pymongo.errors.WriteError: An empty update path is not valid.
def import_fame_dump(input_file='AB.csv'):
fame_export = csv.DictReader(open(input_file), dialect='excel')
leads = []
fame_export.fieldnames + ['ImportDate']
for row in fame_export:
row['ImportDate'] = datetime.datetime.utcnow()
#leads.append(row)
result = db.leads.update_one({
'match1': row['match1'],
'match2': row['match2'],
'match3': row['match3'],
'match4': row['match4']
}, {"$set": row },
upsert=True)
Many thanks for any assistance.