Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- states = {}
- state_name = None
- for line in open("superdeleg.txt").readlines():
- line = line.rstrip()
- if len(line) == 0:
- continue
- words = line.split(" ")
- if len(words) in [1, 2, 3] and \
- line[0] not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] and \
- words[0] == words[0].upper() and \
- len(words[0]) > 1:
- state_name = line
- continue
- if line[0:41] == " ":
- person = line[41:74].rstrip()
- people = states.get(state_name, [])
- people.append(person)
- states[state_name] = people
- if line[42:74] == "":
- title = line[76:123].rstrip()
- titles = people.get(person_name, [])
- titles.append(title)
- people[person_name] = titles
- names = states.keys()
- names.sort()
- print "<table border=1>"
- for state_name in names:
- print "<tr><td>%s</td><td></td></tr>" % state_name
- people = states[state_name]
- total = 0
- for person in people:
- total += 1
- print "<tr><td></td><td>%s</td><td>%s</td></tr>" % (person, title)
- print "<tr><td></td><td><b>TOTAL</b></td><td>%s</td></tr>" % total
- print "</table>"
Add Comment
Please, Sign In to add comment