-
Notifications
You must be signed in to change notification settings - Fork 1
/
boes.py
30 lines (26 loc) · 821 Bytes
/
boes.py
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
29
30
import re
# Board of elections contact info, sorted in the same order as the values used for COUNTYCODE.
f = open('boes-sorted.txt')
boes = []
for line in f:
county = line.strip()
entry = [county]
while True:
line = f.next().strip()
if not line:
break
entry.append(line)
assert re.match('\(\d{3}\) \d{3}-\d{4}', entry[-1]), 'Last line is phone number'
addr = {}
addr['fname'] = '%s County Board of Elections' % county
addr['lname'] = ''
addr['state'] = 'NY'
addr['phone'] = entry[-1]
city, statezip = entry[-2].split(',')
addr['city'] = city
state, zip_ = statezip.split()
assert state == 'NY'
assert re.match('\d{5}', zip_)
addr['zip'] = zip_
addr['street'] = '<br/>\n'.join(entry[1:-2])
boes.append(addr)