SHARE
TWEET

handskrivna röster

a guest Aug 18th, 2012 30 Never
  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')
RAW Paste Data
Top