0
我正在將一系列mongo集合導出到csv文件。我明確設置字段名稱通過調用字典導出,如果字段不存在於給定的文檔中,我仍然想在csv列中創建一個空字段Mongoexport空白字段csv
我目前正在收到這些錯誤在我的控制檯中: too many positional arguments: ['pfrm_uid', 'mark']]
這發生在所有集合上。我發現最奇怪的是在錯誤中有2個右括號。
for item_name in self.exported_fields_Dict.keys():
fields_to_export = self.exported_fields_Dict[item_name]
self.item_count_dict[item_name] = self.item_count_dict[item_name] + 1
os.system("mongoexport --host localhost
--collection {0}
--db scrapy-mongodb-test
--type=csv
--out {1}.csv
--fields {2}".format(
item_name,
item_name,
fields_to_export))
下面是我從
// collection name : fields_to_export
exported_fields_Dict = {
'ent_pfrm': ['pfrm_uid', 'mark'],
'ent_indv': ['indv_uid', 'fName', 'lName', 'gender', 'DOB'],
'ent_meet': ['meet_uid', 'name', 'start_date', 'end_date']
}
拉動集合名稱和字段名字典任何提示/建議表示讚賞!
謝謝@thanasisp! – Chris