Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Last active November 2, 2015 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaizemberg/34c0be07ee448dc21cfa to your computer and use it in GitHub Desktop.
Save aaizemberg/34c0be07ee448dc21cfa to your computer and use it in GitHub Desktop.
BA ECOBICI bicicletas disponibles ( xml --> tsv )
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