Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.