Notebook: using jsonstat.py with cso.ie dataset

This Jupyter notebook shows the python library jsonstat.py in action. It shows how to explore dataset from cso.ie data provider.


In [1]:
# all import here
import os
import jsonstat

using a cache_dir

Caching can speed the development, and provides consistent results.


In [2]:
cache_dir = os.path.abspath(os.path.join("..", "tests", "fixtures", "www.cso.ie"))
jsonstat.cache_dir(cache_dir)


Out[2]:
'/Users/26fe_nas/gioprj.on_mac/prj.python/jsonstat.py/tests/fixtures/www.cso.ie'

using NQQ25 dataset


In [3]:
base_uri = 'http://www.cso.ie/StatbankServices/StatbankServices.svc/jsonservice/responseinstance/'
uri = base_uri + "NQQ25"
filename = "cso_ie-NQQ25.json"

In [4]:
collection_1 = jsonstat.from_url(uri, filename)
collection_1


Out[4]:
JsonstatCollection contains the following JsonStatDataSet:
posdataset
0'dataset'

Previous collection contains only a dataset named 'nama_gdp_c'


In [5]:
dataset = collection_1.dataset(0)
dataset


Out[5]:
name: 'dataset'label: 'Gross Domestic Product at Constant Factor Cost (chain linked annually and referenced to 2013) by Sector, Quarter and Statistic'source: 'Gross Domestic Product at Constant Factor Cost (chain linked annually and referenced to 2013) by Sector, Quarter and Statistic'size: 1216
posidlabelsizerole
0SectorSector8
1QuarterQuarter76time
2StatisticStatistic2metric

In [6]:
dataset.dimension('Sector')


Out[6]:
posidxlabel
0'0''All Sectors'
1'01''Agriculture Forestry and Fishing'
2'02''Industry'
3'03''Distribution Transport Software and Communication'
.........

In [7]:
dataset.dimension('Quarter')


Out[7]:
posidxlabel
0'1997Q1''1997Q1'
1'1997Q2''1997Q2'
2'1997Q3''1997Q3'
3'1997Q4''1997Q4'
.........

In [8]:
dataset.dimension('Statistic')


Out[8]:
posidxlabel
0'NQQ25C01''Gross Domestic Product at Constant Factor Cost (chain linked annually and referenced to 2013) (Euro Million)'
1'NQQ25S1''Gross Domestic Product at Constant Factor Cost (chain linked annually and referenced to 2013) (Seasonally Adjusted) (Euro Million)'

Get value for year 2012.


In [9]:
dataset.data(Sector='03', Quarter='1997Q4', Statistic='NQQ25S1')


Out[9]:
JsonStatValue(idx=463, value=5998, status=None)