我有一个包含多个字典的JSON文件:
{"team1participants":
[ {
"stats": {
"item1": 3153,
"totalScore": 0,
...
}
},
{
"stats": {
"item1": 2123,
"totalScore": 5,
...
}
},
{
"stats": {
"item1": 1253,
"totalScore": 1,
...
}
}
],
"team2participants":
[ {
"stats": {
"item1": 1853,
"totalScore": 2,
...
}
},
{
"stats": {
"item1": 21523,
"totalScore": 5,
...
}
},
{
"stats": {
"item1": 12503,
"totalScore": 1,
...
}
}
]
}
换句话说,JSON有多个键。每个键都有一个包含单个参与者统计信息的列表。在
我有很多这样的JSON文件,我想把它解压成一个CSV文件。我当然可以手动完成,但这很乏味。我知道听写器,但它似乎只适用于单本词典。我也知道字典可以连接起来,但这会有问题,因为所有字典都有相同的键。在
如何有效地将其提取到CSV文件中?在
您可以使数据整洁,这样每一行都是唯一的观察。在
你也可以使用列表理解来代替循环。在
^{pr2}$然后可以创建透视表,例如:
而且,现在它是一个数据帧,很容易将其保存为CSV。在
相关问题 更多 >
编程相关推荐