Advertisement
Guest User

handskrivna röster

a guest
Aug 18th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. from collections import Counter
  2.  
  3.  
  4. csv = open('handskrivna.skv')
  5.  
  6. rows = []
  7. for line in csv.readlines()[1:]:
  8.     if line:
  9.         line = line.decode('iso-8859-1')
  10.         (valtyp,_,_,_,_,_,_,_,_,parti,antal) = line.split(';')
  11.         if valtyp == "R":
  12.             for i in xrange(int(antal)):
  13.                 rows.append(parti)
  14.  
  15. freqs = Counter(rows)
  16. for (parti, antal) in freqs.most_common():
  17.     print ("<tr><td>%s</td><td>%s</td></tr>" % (parti, antal)).encode('utf-8')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement