Skip to content

Commit bc63fac

Browse files
committed
Merge branch 'master' of https://github.com/jsonstat/conv
2 parents ab8a1ca + 498fc26 commit bc63fac

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Check the [API Reference](https://github.com/jsonstat/conv/blob/master/docs/API.
3131
Get unemployment rate time series by country from Eurostat and convert it to CSV.
3232

3333
```
34-
curl "https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1" -o unr.jsonstat
34+
curl "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120" -o unr.jsonstat
3535
3636
jsonstat2csv unr.jsonstat unr.csv
3737
```
3838

3939
Or using the stream interface:
4040

4141
```
42-
curl "https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1" | jsonstat2csv > unr.csv -t
42+
curl "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120" | jsonstat2csv > unr.csv -t
4343
```
4444

4545
More in the [Examples](https://github.com/jsonstat/conv/blob/master/docs/EXAMPLES.md) page.

docs/API.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,23 @@ String. Specifies the label of the status field. Default is "Status".
335335
jsonstat2csv oecd.json oecd.csv --status --slabel stat
336336
```
337337

338+
#### --fid (-f)
339+
340+
Boolean. Identifies dimensions, value and status by ID instead of label.
341+
342+
```
343+
jsonstat2csv oecd.json oecd.csv --fid
344+
```
345+
346+
#### --cid (-c)
347+
348+
Boolean. Identifies categories by ID instead of label.
349+
350+
```
351+
jsonstat2csv oecd.json oecd.csv --cid
352+
```
353+
354+
338355
#### --na (-n)
339356

340357
String. Not available text. Default is "n/a".

docs/EXAMPLES.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ Tables on EU policy
3737

3838
Connect to the JSON-stat Eurostat API to retrieve dataset **tesem120**:
3939

40-
https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1
40+
https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120
4141

4242
You can view the contents of the dataset at
4343

44-
https://jsonstat.com/explorer/#/https%3A%2F%2Fec.europa.eu%2Feurostat%2Fwdds%2Frest%2Fdata%2Fv2.1%2Fjson%2Fen%2Ftesem120%3Fprecision%3D1
44+
https://jsonstat.com/explorer/#/https%3A%2F%2Fec.europa.eu%2Feurostat%2Fapi%2Fdissemination%2Fstatistics%2F1.0%2Fdata%2Ftesem120
4545

4646
To download the dataset from the command line using Eurostat's API, run [cURL](https://curl.haxx.se/dlwiz/?type=bin):
4747

4848
```
49-
curl "https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1" -o eurostat.jsonstat
49+
curl "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120" -o eurostat.jsonstat
5050
```
5151

5252
JSON-stat keeps data and metadata completely apart because it is designed to be an efficient transport format. That probably makes it human-unfriendly. Fortunately, we can use jsonstat-conv to convert JSON-stat to other formats.
@@ -195,7 +195,7 @@ json2csv < eurostat-comma.json > eurostat-semi.csv -w ";"
195195
All the process has required three lines and three files (_eurostat.jsonstat_, _eurostat-drop.json_, _eurostat.csv_):
196196

197197
```
198-
curl "https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1" -o eurostat.jsonstat
198+
curl "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120" -o eurostat.jsonstat
199199
200200
jsonstatdice eurostat.jsonstat eurostat-subset.jsonstat --filter sex=T,age=Y15-74,unit=PC_ACT
201201
@@ -221,19 +221,19 @@ jsonstat2arrobj < eurostat.jsonstat > eurostat.json --stream
221221
So to get a comma-delimited CSV with dot as the decimal mark in a single line:
222222

223223
```
224-
curl "https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1" | jsonstatdice --filter sex=T,age=Y15-74,unit=PC_ACT --stream | jsonstat2arrobj --by geo --drop sex,age,unit --stream | json2csv > eurostat.csv
224+
curl "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120" | jsonstatdice --filter sex=T,age=Y15-74,unit=PC_ACT --stream | jsonstat2arrobj --by geo --drop sex,age,unit --stream | json2csv > eurostat.csv
225225
```
226226

227227
Or a little shorter:
228228

229229
```
230-
curl "https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1" | jsonstatdice -f sex=T,age=Y15-74,unit=PC_ACT -t | jsonstat2arrobj -b geo -d sex,age,unit -t | json2csv > eurostat.csv
230+
curl "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120" | jsonstatdice -f sex=T,age=Y15-74,unit=PC_ACT -t | jsonstat2arrobj -b geo -d sex,age,unit -t | json2csv > eurostat.csv
231231
```
232232

233233
And to get a semicolon-delimited CSV with comma as the decimal mark:
234234

235235
```
236-
curl "https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?precision=1" | jsonstatdice -f sex=T,age=Y15-74,unit=PC_ACT -t | jsonstat2arrobj -b geo -d sex,age,unit -k -t | json2csv > eurostat-semi.csv -w ";"
236+
curl "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120" | jsonstatdice -f sex=T,age=Y15-74,unit=PC_ACT -t | jsonstat2arrobj -b geo -d sex,age,unit -k -t | json2csv > eurostat-semi.csv -w ";"
237237
```
238238

239239
## A UNECE Example

jsonstat2csv

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ var
2525
.describe("v", "Label of the value field (default is 'Value')")
2626
.alias("l", "slabel")
2727
.describe("l", "Label of the status field (default is 'Status')")
28+
.boolean("f")
29+
.alias("f", "fid")
30+
.describe("f", "Use field IDs instead of labels.")
31+
.boolean("o")
32+
.alias("o", "cid")
33+
.describe("o", "Use content IDs instead of labels.")
2834
.alias("y", "by")
2935
.describe("y", "Dimension to transposed by")
30-
.alias("o", "drop")
31-
.describe("o", "Comma-separated list of constant dimensions to remove when a valid 'by' is specified.")
36+
.alias("p", "drop")
37+
.describe("p", "Comma-separated list of constant dimensions to remove when a valid 'by' is specified.")
3238
.boolean("b")
3339
.alias("b", "big")
3440
.describe("b", "This is an emergency option only to be used when the stream interface is not enabled and the dataset is very big.")
@@ -51,6 +57,8 @@ var
5157
status: argv.status,
5258
vlabel: argv.vlabel,
5359
slabel: argv.slabel,
60+
field: argv.fid ? "id" : "label",
61+
content: argv.cid ? "id" : "label",
5462
na: argv.na,
5563
delimiter: (argv.column==="\\t") ? "\t" : argv.column,
5664
separator: (argv.unit==="\\t") ? "\t" : argv.unit,

0 commit comments

Comments
 (0)