【发布时间】:2020-12-19 11:27:06
【问题描述】:
我有一个嵌套的 json 文件可以将其转换为 csv 。下面是 json 格式,
[{'year': '2020' },
('data', [{'location': {'coordinates': {'lat': 22.0, 'lon': -33.0}},
'times': {'date': '2020-08-30', 'time': '12:00'},
'values': {'surface': 45, 'wave': 6.8, 'temp': 283, 'height': 1.8}},
{'location': {'coordinates': {'lat': 22, 'lon': -33}},
'times': {'date': '2020-08-30', 'time': '13:00'},
'values': {'surface': 42, 'wave': 6.7, 'temp': 283.1, 'height': 2.88}})]
这些json格式要转换成csv:
需要的输出如下:
lat lon date time surface wave temp height
22 -33 2020-08-30 12:00 45 6.8 283 1.8
22 -33 2020-08-30 13.00 42 6.7 283.1 2.88
【问题讨论】:
-
你试过什么?你被困在哪里了?
-
您发布的json无效
标签: python json python-3.x pandas csv