Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# coding: utf-8
# requirements: requests rows xmltodict
from collections import OrderedDict
import requests
import rows
import xmltodict
class PtBrDateField(rows.fields.DateField):
INPUT_FORMAT = '%d/%m/%Y'
url = ''
fields = OrderedDict([('codigo', rows.fields.IntegerField),
('nome', rows.fields.TextField),
('data_votacao', PtBrDateField)])
response = requests.get(url)
result = xmltodict.parse(response.content)
table = rows.Table(fields=fields)
for proposicao in result['proposicoes']['proposicao']:
table.append({'codigo': proposicao['codProposicao'],
'nome': proposicao['nomeProposicao'],
'data_votacao': proposicao['dataVotacao'], })
rows.export_to_csv(table, 'proposicoes.csv')
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.