summaryrefslogtreecommitdiff
path: root/ballots.py
blob: d822d84b1693fbc1898ebc997bcfd09a11a3071b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import re

def read_file(filename):
    with open(filename, 'r') as f:
        return f.read()

def get_ballots(f):
    BALLOT_DATA_RE = re.compile(
        r'(\d\d)\n(.*)\n(\d\d\d\d)\n(.*)\n([\d\.]+)\n(.*)\n(.*)')
    m = re.findall(BALLOT_DATA_RE, f)
    for x in m:
        commitee_id, commitee, city_id, city, ballot_id, ballot_address, ballot_location = x
        print commitee_id, commitee, city_id, city, ballot_id, ballot_address, ballot_location

f = read_file('ballots.txt')
data = get_ballots(f)
print data