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
@aivuk

This comment has been minimized.

Copy link
Owner Author

commented May 21, 2015

S.Part. 6
PRTB 14
PSL 14
PTdoB 15
PEN 20
PTC 25
PSDC 27
PRP 40
PMN 42
PHS 50
PTN 51
PSOL 54
PV 88
PPS 120
PSC 128
PROS 143
PCdoB 157
Solidaried 185
PRB 215
DEM 221
PDT 261
PTB 285
PSB 387
PSD 398
PR 411
PP 470
PSDB 579
PT 777
PMDB 780

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.