我正在尝试遍历文件夹中的文件列表。在遍历它们时,我想添加它们中的每一个。但是,我收到TypeError:“collection”对象不可调用
我试着改变目录和访问mlab的方式,但没有效果。我不确定文件名中是否有空格是个问题。我试着修改了几个文件,但还是一样的问题
URI = 'mongodb://test:fake_pass@ds149984.mlab.com:49984/try2'
client = MongoClient(URI)
collection_sudo_freedom = client['sudo_freedom']
directory = os.listdir('C:/Users/Maximvs/Documents/Scraper_Plans')
print(len(directory))
for file in directory:
# print(type)file)
folder = 'C:/Users/Maximvs/Documents/Scraper_Plans/'
Datafile = file
fullDirectory = folder + Datafile
# print(fullDirectory)
with open(fullDirectory) as f:
file_data = json.load(f)
collection_sudo_freedom.insert_one(file_data)
client.close()
我想上传我的文件夹中的所有312个文件到mlabs(sudo\u自由收集)
目前没有回答
相关问题 更多 >
编程相关推荐