我有一个嵌套的JSON文件,需要将其转换为CSV。
我正在尝试通过使用Python pandas和json_normalize方法进行转换。
但是无法获得预期的输出。这是我的示例JSON文件。
{"issues": [{"id": 520,"project": {"id": 2,"name": "Partner Training Program"},"custom_fields": [{"id": 4,"name": "Content Owner","value": "Sin Yong Chuah"},{"id": 19,"name": "Course Languages","multiple": true,"value": ["English","Chinese Traditional","Indonesian (MT)","Japanese","Korean","Thai (MT)","Vietnamese"]}]}]}
我正在寻找下面几栏的csv
issues_id, issues_project_id,issues_project_name,custom_fields_id,custom_fields_name,custom_fields_value
这是我用来转换的python代码
json_file=open(input_file_name).read()
jon_data=json.loads(json_file)
df=json_normalize(json_data['issues'])
df.to_csv(output_file_name,index=False)