将JSON输出转换为CSV以用于AWS API输出client.describe_trusted_advisor_check_result
。
我想用Python中的脚本将输出JSON转换为CSV。我得到的JSON输出是嵌套的。
`
import json
import csv
with open('idcheck.json', 'r') as f:
json_dict = json.load(f)
# Open new CSV file
with open("output5.csv", "w") as csv_file:
writer = csv.writer(csv_file)
# Write CSV headers
# Write data to CSV for each image
images_data = json_dict['result']['flaggedResources']
for image in images_data:
writer.writerow([images_data['status'],
images_data['region'],
images_data['resourceId'],
images_data['isSuppressed']])
`