Last active
November 2, 2015 20:37
-
-
Save aaizemberg/34c0be07ee448dc21cfa to your computer and use it in GitHub Desktop.
BA ECOBICI bicicletas disponibles ( xml --> tsv )
This file contains 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 requests | |
import xml.etree.ElementTree as ET | |
r = requests.get('https://recursos-data.buenosaires.gob.ar/ckan2/ecobici/estado-ecobici.xml') | |
root = ET.fromstring( r.text.encode('utf-8') ) | |
estaciones = root[0][0][0][0][0] | |
f = open('estaciones.tsv', 'w') | |
s = 'EstacionId EstacionNombre BicicletaDisponibles EstacionDisponible Latitud Longitud Numero Lugar Piso AnclajesTotales AnclajesDisponibles\n' | |
f.write( s ) | |
for e in estaciones: | |
s = '' | |
for e1 in e: | |
if e1.text is None: | |
s = s + '\t' | |
else: | |
s = s + e1.text.encode('iso-8859-1').strip() + '\t' | |
s = s[0:len(s)-1] + '\n' | |
f.write( s ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment