我有一个 JSON 文件data.json
,其中包含大型高音扬声器记录。我正在尝试将此 JSON 文件加载到 Jupyter,然后传输到 pandas 数据框以进行进一步分析。到目前为止,我已经编写了以下代码:推文示例是'{"_id":{"$oid":"5ec248611c9b498cdbf095a1"},"created_at":"Mon Dec 31 23:19:39 +0000 2018","id":{"$numberLong":"1079879790738325504"},"id_str":"1079879790738325504","text":"NPAF's Artist in Residence, Composer Glenn McClure is at the Park at work on his unusual sonification compostions
import json
import csv
json_file = "\\Users\\data.json"
header = ["id_str", "created_at", "lang", "text"]
tweets_processed = 0
with open(json_file, 'r') as infile:
print("json file: ", json_file)
for line in infile:
tweet = json.loads(line)
#row = [tweet['id_str'], tweet['created_at'], tweet['lang'], tweet['text']]
#csvwriter.writerow(row)
tweets_processed += 1
#print("tweet processed: ", tweet_processed)
到目前为止,这是我编写的代码,基本上是为了读取我的 json 文件并将其传递给 pandas 数据框。关于如何将我的 json 数据放入 pandas 数据框的任何帮助?提前致谢。