2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > mongodb导入JSON数据报错:Document is larger than the maximum size

mongodb导入JSON数据报错:Document is larger than the maximum size

时间:2018-07-14 13:12:48

相关推荐

mongodb导入JSON数据报错:Document is larger than the maximum size

mongodb导入数据报错:Document is larger than the maximum size,提示文件太大,用pandas读取,然后一行一行写入到数据库,特记此笔记。

import jsonimport pymongoimport pandas as pdclient = pymongo.MongoClient('localhost', 27017) # 连接数据库collection = client['Databasename']["collectionname"] # 加载数据with open("json文件路径", "r", encoding="UTF-8") as f: # 读取json文件datas = json.load(f)df = pd.DataFrame(datas) # 将json转换为dfprint(df.shape)for num_index, valuelists in df.iterrows(): # 按行遍历collection.insert_one(valuelists.to_dict()) # 写入mongodbprint("done")

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。