Profile cover photo
Profile photo
A simple light standard for all kinds of data disseminators
A simple light standard for all kinds of data disseminators

JSON-stat's posts

Post has attachment
JSON-stat Command Line Conversions Tools: Examples

Step by step examples of converting JSON-stat data from Eurostat, UNECE, Statistics Norway, the Central Statistics Office of Ireland and Statistics Denmark:

#json #api #stats #csv #jsonstat #opendata

Post has shared content

Using the new capabilities of the stream interface of jsonstat-conv

This example uses jsonstat-conv (0.4.2 or greater) in combination with ndjson-cli. If they are not installed in your system,

npm install -g jsonstat-conv
npm install -g ndjson-cli

The goal is to get (without generating intermediate files) an array of objects with three string elements (time, geo and unr):

{ "time": "2003", "geo": "Australia", "unr": "5.943826289 %" }

The steps are:

1) Use CURL to retrieve the oecd.json dataset.

2) Use jsonstat2arrobj to convert the JSON-stat response into an array of objects with unit information (-u).

3) Use ndjson-split to translate JSON into NDJSON.

4) Use ndjson-map to transform each object into a new object with the desired structure.

5) Use ndjson-reduce to translate NDJSON back to JSON and save it as output.json.

The single line solution:

curl '' | jsonstat2arrobj -u -t | ndjson-split | ndjson-map '{time: d.year, geo: d.area, unr: d.value.toFixed(d.unit.decimals) + " " + d.unit.symbol}' | ndjson-reduce > output.json_

Post has shared content
How to convert JSON-stat to a simplified array

Sometimes you need the simplest possible array of data (without a header, without useless columns). This example requires CURL, jsonstat-conv and ndjson-cli.

To install jsonstat-conv and ndjson-cli:

npm install -g jsonstat-conv

npm install -g ndjson-cli

In this example:

1) Retrieve unemployment rate time series by country (discard sex and age) from Eurostat in the JSON-stat format.

2) Convert JSON-stat into a JSON array, with categories identified by ID instead of label.

3) Convert JSON into NDJSON (

4) Remove the first three elements (age, unit, sex) in each array (they are constant).

5) Remove the header line.

6) Convert NDJSON back to JSON.

curl '' -o unr.jsonstat

jsonstat2array unr.jsonstat unr.json -c

ndjson-split < unr.json > unr.ndjson

ndjson-map '[d[3],d[4],d[5]]' < unr.ndjson > unr-3cols.ndjson

ndjson-filter 'i' < unr-3cols.ndjson > unr-3cols-nohead.ndjson

ndjson-reduce < unr-3cols-nohead.ndjson > unr-3cols-nohead.json

Or only in two lines:

jsonstat2array unr.jsonstat unr.json -c

ndjson-split < unr.json | ndjson-map '[d[3],d[4],d[5]]' | ndjson-filter 'i' | ndjson-reduce > unr-3cols-nohead.json

Post has attachment
Using the JSON-stat conversion tools with Nordic data

The Nordic countries currently support JSON-stat in the form of bundles with a single dataset. Besides, most of them require to POST a query to retrieve data.

To retrieve the unemployment rate time series (latest 16 quarters) by sex from Statistics Norway:

curl -X POST -d '{ "query": [ { "code": "Kjonn", "selection": { "filter": "item", "values": [ "0", "1", "2" ] } }, { "code": "ContentsCode", "selection": { "filter": "item", "values": [ "Prosent" ] } }, { "code": "Tid", "selection": { "filter": "top", "values": ["16"] } } ], "response": { "format": "json-stat" } }' -o unr.json

To convert to CSV:

jsonstat2csv unr.json unr.csv

(When dealing with bundles, the JSON-stat Command Line Conversion Tools will automatically select the first dataset in the bundle.)

Post has shared content
Connect to a JSON-stat data provider and convert some dataset into CSV or into popular JSON flavors... in two simple steps.

#csv #json #stats #cube #opendata
I've published some command line tools for converting JSON-stat documents into different flavors of JSON and CSV.

Assuming you have node.js and NPM installed in your computer, type

npm install -g jsonstat-conv

to install the tools. After that, your system will have the following commands available:

jsonstat2array - converts JSON-stat into a JSON array of arrays
jsonstat2arrobj - converts JSON-stat into a JSON array of objects
jsonstat2object - converts JSON-stat into a JSON object
jsonstat2csv - converts JSON-stat into CSV

Assuming you have CURL installed, getting the unemployment rate by countries from Eurostat as a CSV is as simple as:

curl '' -o unr.json

jsonstat2csv unr.json unr.csv

Post has attachment
The wonderful story of rjstat (JSON-stat #R package) by +Aaron Schumacher

#rproject #stats

Post has attachment
JSON-stat 2.0 for Java now available

Statistics Norway has taken over the Java code for JSON-stat

#java #json #stats #cube #opendata

Post has attachment
JSON-stat cool t-shirts to support the hosting costs of

Post has attachment
An example of using the Fetch API to retrieve a dataset from Statistics Sweden in the JSON-stat format:

Post has attachment
Wait while more posts are being loaded