JsonStatCollection

class jsonstat.JsonStatCollection[source]

Represents a jsonstat collection.

It contains one or more datasets.

>>> import os, jsonstat  
>>> filename = os.path.join(jsonstat._examples_dir, "www.json-stat.org", "oecd-canada-col.json")
>>> collection = jsonstat.from_file(filename)
>>> len(collection)
2
>>> collection
JsonstatCollection contains the following JsonStatDataSet:
+-----+-----------------------------------------------------+
| pos | dataset                                             |
+-----+-----------------------------------------------------+
| 0   | 'Unemployment rate in the OECD countries 2003-2014' |
| 1   | 'Population by sex and age group. Canada. 2012'     |
+-----+-----------------------------------------------------+
__len__()[source]

the number of dataset contained in this collection

dataset(spec)[source]

select a dataset belonging to the collection

Parameters:spec

can be

  • the name of collection (string) for jsonstat v1
  • an integer (for jsonstat v1 and v2)
Returns:a JsonStatDataSet object

parsing

JsonStatCollection.from_file()[source]

initialize this collection from a file It is better to use jsonstat.from_file()

Parameters:filename – name containing a jsonstat
Returns:itself to chain call
JsonStatCollection.from_string()[source]

Initialize this collection from a string It is better to use jsonstat.from_string()

Parameters:json_string – string containing a json
Returns:itself to chain call
JsonStatCollection.from_json()[source]

initialize this collection from a json structure It is better to use jsonstat.from_json()

Parameters:json_data – data structure (dictionary) representing a json
Returns:itself to chain call