Guest User

Untitled

a guest
Apr 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. states = {}
  2. state_name = None
  3.  
  4. for line in open("superdeleg.txt").readlines():
  5. line = line.rstrip()
  6. if len(line) == 0:
  7. continue
  8. words = line.split(" ")
  9. if len(words) in [1, 2, 3] and \
  10. line[0] not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] and \
  11. words[0] == words[0].upper() and \
  12. len(words[0]) > 1:
  13. state_name = line
  14. continue
  15.  
  16. if line[0:41] == " ":
  17. person = line[41:74].rstrip()
  18. people = states.get(state_name, [])
  19. people.append(person)
  20. states[state_name] = people
  21.  
  22. if line[42:74] == "":
  23. title = line[76:123].rstrip()
  24. titles = people.get(person_name, [])
  25. titles.append(title)
  26. people[person_name] = titles
  27.  
  28. names = states.keys()
  29. names.sort()
  30. print "<table border=1>"
  31. for state_name in names:
  32. print "<tr><td>%s</td><td></td></tr>" % state_name
  33. people = states[state_name]
  34. total = 0
  35. for person in people:
  36. total += 1
  37. print "<tr><td></td><td>%s</td><td>%s</td></tr>" % (person, title)
  38.  
  39. print "<tr><td></td><td><b>TOTAL</b></td><td>%s</td></tr>" % total
  40.  
  41. print "</table>"
Add Comment
Please, Sign In to add comment