This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

handskrivna röster

By: a guest on Aug 18th, 2012  |  syntax: Python  |  size: 0.48 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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')
clone this paste RAW Paste Data