Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import csv
- import json
- from collections import defaultdict
- def rec_dd():
- return defaultdict(rec_dd)
- d = {'countries': rec_dd()}
- with open('vassilis.csv') as csvfile:
- reader = csv.DictReader(csvfile)
- for row in reader:
- d['countries'][row['country_origin']][row['year']][row['month']] = row['value']
- print(json.dumps(d))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement