Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python json数据存储为一行_Python_Json_Pandas_Mongodb - Fatal编程技术网

Python json数据存储为一行

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 =

当我尝试将数据存储在mongodb中时,它会存储为一行。 如何将其存储为多行?

尝试insertMany()方法

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>
   }
)