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
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值