forked from Hristiyan-Bonev/python-descriptors-abc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (18 loc) · 683 Bytes
/
main.py
File metadata and controls
28 lines (18 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import logging
from models.person import Person
logging.basicConfig(level=logging.DEBUG)
if __name__ == '__main__':
data = json.load(open('resources/person.json'))
out = [Person(**d) for d in data]
outt = json.loads(json.dumps(out, default = lambda x: x.__dict__))
# To XML
# import csv
# with open('dict.csv', 'w') as csv_file:
# writer = csv.DictWriter(csv_file, fieldnames=outt[0].keys())
# writer.writeheader()
# for item in outt:
# writer.writerow(item)
# To JSON [TODO]
# with open('out.json', 'w') as out_file:
# out_file.write(json.dumps(outt, indent=4, sort_keys=True))