-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan.py
More file actions
28 lines (22 loc) · 702 Bytes
/
scan.py
File metadata and controls
28 lines (22 loc) · 702 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
# Takes cities.json and runs through all the different regimes mentioned.
# Compiles a complete list of all regimes.
import codecs
import json
contents = []
d = codecs.open("cities.json", 'r', "utf-8-sig")
contents = json.load(d)
regimes = []
history = [item.get('history') for item in contents]
for date in history:
for entry in date:
regime = entry["regime"]
event_bool = 1
if "type" in entry:
event_type = entry["type"]
if event_type == 0:
event_bool = 0
if regime not in regimes and event_bool:
regimes.append(regime)
s = json.dumps(regimes, indent=4)
with open("regimes.json", 'w') as f:
f.write(s)