试图将这个大json转换成csv。这里是示例JSON
[
[{
"User": "Phoebe",
"text": "Oh my God, hes lost it. Hes totally lost it.",
"sent": "non-neutral"
},
{
"user": "Monica",
"text": "What?",
"sent": "surprise"
}
],
[{
"user": "Joey",
"text": "Hey Estelle, listen",
"sent": "neutral"
},
{
"user": "Estelle",
"text": "Well! Well! Well! Joey Tribbiani! So you came back huh? They",
"sent": "surprise"
}
]
]
with open('/Users/dsg281/Downloads/EmotionLines/Friends/friends_dev.json') as data_file:
data = json.load(data_file)
我正在尝试在csv
中获取包含“User”,“text”,“sent”
我认为需要(将json更改为valid之后):
file.json
^{pr2}$
然后:
编辑:
如果要使用非pandas纯python解决方案,可以对this solution进行一点修改:
如果我们提供一个空列表的起始值
[]
,我们可以将这些列表与sum
结合起来相关问题 更多 >
编程相关推荐