-
-
Save everton137/759cdce95b397b48a5e9 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