Skip to content

Instantly share code, notes, and snippets.

@bubbobne
Last active September 25, 2018 08:57
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 bubbobne/850813266ec6bafad62a3da906ae09cf to your computer and use it in GitHub Desktop.
Save bubbobne/850813266ec6bafad62a3da906ae09cf to your computer and use it in GitHub Desktop.
get meteo trentino stations info by codice
import csv
import xml.etree.ElementTree
e = xml.etree.ElementTree.parse('listaStazioni.xml').getroot()
with open('./codiceStazioni.csv',newline="") as csvfile:
id_stazioni=csv.reader(csvfile,delimiter=",")
with open('./outputStazione.csv','w',newline="") as outFile:
out=csv.writer(outFile,delimiter=",")
header = ('codice', 'nome', 'nomebreve', 'quota','latitudine','longitudine','est','nord')
out.writerow(header)
for id_stazione in id_stazioni:
for elem in e.findall('anagrafica'):
if id_stazione[0]==elem.find('codice').text:
row = elem.find('codice').text,elem.find('nome').text,elem.find('nomebreve').text,elem.find('quota').text,elem.find('latitudine').text,elem.find('longitudine').text,elem.find('est').text,elem.find('north').text
out.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment