Python json数据存储为一行
当我尝试将数据存储在mongodb中时,它会存储为一行。 如何将其存储为多行?尝试insertMany()方法Python json数据存储为一行,python,json,pandas,mongodb,Python,Json,Pandas,Mongodb,当我尝试将数据存储在mongodb中时,它会存储为一行。 如何将其存储为多行?尝试insertMany()方法 db.collection.insertMany( [ , ... ], { writeConcern:, 命令: } ) 这是mongodb站点中的文档:您的json文件的模式如何?您可以添加它吗? import json from pymongo import MongoClient client = MongoClient('localhost', 27017) db =
db.collection.insertMany(
[ , ... ],
{
writeConcern:,
命令:
}
)
这是mongodb站点中的文档:您的json文件的模式如何?您可以添加它吗?
import json
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client['zomato_db']
collection_zomato = db['zomatores']
with open('E:\\DAPProject\\Datasets\\ZOMATORES.json') as f:
file_data = json.load(f)
collection_zomato.insert_one(file_data)
client.close()
db.collection.insertMany(
[ <document 1> , <document 2>, ... ],
{
writeConcern: <document>,
ordered: <boolean>
}
)