About the pyjstat library for json

0

I'm trying to read a json with pyjstat but it gives me an error:

  

KeyError: 'dimension'

This is the code:

from pyjstat import pyjstat

EXAMPLE_URL ='http://www.cso.ie/StatbankServices/StatbankServices.svc/jsonservice/responseinstance/AQA04'
query = [{'Type of Crop': 'Total wheat'}, {'Year': '2008'}, {'Statistic': 'AQA04C2'}]
dataset = pyjstat.Dataset.read(EXAMPLE_URL)
print(dataset.get_value(query))

I do not know much about the library, but from what I've seen it looks for a field ['dimension']['id'] but the json if it has it and I do not know why it gives an error ... Does anyone understand it?

Thanks

    
asked by Ulises 2010 11.04.2017 в 18:40
source

1 answer

0

It seems that the JSON format of the URL you provide is not correct for this library. It is not able to read the key "dimension" and that is because it requires the top level. If you delete the "dataset" level if you read that key "dimension" but it still keeps giving problems.

According to the creators it works with Python 3.4 They also indicate that they require jstat 2.0 since 1.3 is outdated, in fact the example they use is with jstat 2.0

    
answered by 11.04.2017 в 21:12