pondělí 28. března 2016

eurostat rest api python

https://www.codecademy.com/users/megaSolver91781/achievements

62% zbyva


tak jsem si pohral s eurostatem a po hodine ( mel jsem trosku probemy s defaultni xml knihovnou v 3.5)  mam seznam datasetu:

eurostat REST api   dataset list

from xml.etree import ElementTree
ALL_DATASETS_URL=r"http://www.ec.europa.eu/eurostat/SDMX/diss-web/rest/dataflow/ESTAT/all/latest"
response = requests.get(ALL_DATASETS_URL)
tree = ElementTree.fromstring(response.content)
datasets={}
for child in tree.iter('{http://www.sdmx.org/resources/sdmxml/schemas/v2_1/structure}Dataflows'):
    for childa in child.iter('{http://www.sdmx.org/resources/sdmxml/schemas/v2_1/structure}Dataflow'):
        agencyID=childa.attrib['agencyID']
        datasetID=childa.attrib['id']
        datasetText=childa[0].text
        datasets[datasetText]={'agencyID':agencyID,                               'datasetID':datasetID
                               }

for kk in datasets.keys():
    print(" dataset :"+kk)

Žádné komentáře:

Okomentovat