1
我希望我可以使用「row」進行$ set設置,因爲它包含我想要更新的所有數據,但會得到以下內容。我的代碼如下:沒有指定所有參數的Upsert
C:\蒙戈腳本> csvimporter.py 回溯(最近最後一次通話): .... pymongo.errors.WriteError:空更新路徑無效。
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)
非常感謝您的任何幫助。