Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json, csv
- output = open('test.csv', 'w+')
- csv_file = csv.writer(output)
- with open('deplike.json', 'r') as json_file:
- data = json.load(json_file)
- """ for p in data:
- csv_file.writerow([unicode(p).encode('ascii')])
- for x in data.itervalues():
- csv_file.writerow([unicode(x).encode('ascii')])"""
- all_keys = ['key']
- all_keys.extend('key%d' % i for i in range(1,6))
- csv_data = [[data[val][key] for key in all_keys] for val in data.keys()]
- with open('test.csv','w+') as outfile:
- write = csv.writer(outfile)
- write.writerows(csv_data)
- json_file.close()
- output.close()
Advertisement
Add Comment
Please, Sign In to add comment