Created
May 21, 2015 13:06
-
-
Save aivuk/0f05533a4797b6d1d62f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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