for entity in json_dict:
    csv_file = open('%s.csv' % entity, 'wb')
headers = list(a[entity][0].keys())
csv_writer = csv.DictWriter(csv_file, headers)
map(csv_writer.writerow, json_dict[entity])
csv_file.close()
Convert JSON to CSV