Skip to content

Instantly share code, notes, and snippets.

@everton137
Forked from aivuk/votos_camara_shopping.py
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save everton137/759cdce95b397b48a5e9 to your computer and use it in GitHub Desktop.
Save everton137/759cdce95b397b48a5e9 to your computer and use it in GitHub Desktop.
import BeautifulSoup as bs
from collections import defaultdict
xml_votos = open('./votos-camara.xml')
xml_data = bs.BeautifulSoup(xml_votos.read())
dpts = xml_data.findAll('deputado')
hist_pt = defaultdict(int)
for d in dpts:
if d['voto'] != u'Não':
hist_pt[d['partido'].strip()] += 1
ordenado = sorted(hist_pt.items(), key=lambda x: x[1])
for partido, votos in ordenado:
print partido, votos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment