Python:json数据转变成Excel数据

import json
import pandas as pd
 
df = pd.read_json('train.json',lines=True,encoding='utf-8')
#lines = true 表示把每一行都看成是一个字典
#train.json是Jason类型的数据文件

df.to_excel('train.xlsx')

train.json文件内容
{“overall”: 2.0, “vote”: “3”, “verified”: true, “reviewTime”: “06 15, 2010”, “reviewerID”: “A1Q6MUU0B2ZDQG”, “asin”: “B00004U9V2”, “reviewerName”: “D. Poston”, “reviewText”: “I bought two of these 8.5 fl oz hand cream, and neither of the dispensers work. The hand cream is wonderful, but very thick, so I don’t see I can get much out by shaking it out, since the dispensers seem to be non-operable.”, “summary”: “dispensers don’t work”, “unixReviewTime”: 1276560000}
{“overall”: 5.0, “vote”: “14”, “verified”: true, “reviewTime”: “01 7, 2010”, “reviewerID”: “A3HO2SQDCZIE9S”, “asin”: “B00004U9V2”, “reviewerName”: “chandra”, “reviewText”: “Believe me, over the years I have tried many, many different hand creams. I am one of those people whose hands get so dry they have little cracks all over them.\n\nOf all the hand creams, this is the best. It really moisturizes but doesn’t leave your hands feeling greasy. And it lasts. I think a lot of lotions just have too much water in them. It has a very nice, subtle scent. I have to avoid a lot of lotions just because the scent is too strong!\n\nI am overall very “frugal” but I think this cream is worth the money.”, “summary”: “Best hand cream ever.”, “unixReviewTime”: 1262822400}
train.xlsx
在这里插入图片描述

你可能感兴趣的:(学习笔记,python,json)