TheEconomist / big-mac-data

Data and methodology for the Big Mac index
https://www.economist.com/bigmac
MIT License
1.58k stars 413 forks source link

Provide a machine-readable data schema using data packages #10

Open vitorbaptista opened 5 years ago

vitorbaptista commented 5 years ago

A data package is a lightweight standard to describe tabular data. In it's simplest form, it's a datapackage.json file like:

{
  "name": "big-mac-data",
  "description": "Lorem ipsum",
  "resources": [
    {
      "name": "big-mac-full-index",
      "path": "output-data/big-mac-full-index.csv",
      "schema": {
        "fields": [
          {
            "name": "date",
            "type": "date",
            "constraints": {
              "required": true
            }
          },
          // ...
        ]
      }
    }
  ]
}

You can see a full example of a data package at https://github.com/vitorbaptista/birmingham_schools.

There are multiple libraries that understand this format, for example https://github.com/frictionlessdata/goodtables-py allows the data to be validated by running goodtables datapackage.json (this can even be run automatically using https://goodtables.io/), https://github.com/frictionlessdata/datapackage-py allows loading the data in Python (automatically validating and casting the data to their specific types), and there are others for R, JavaScript, Ruby and others.

I'd be happy to talk more about it, and/or write a datapackage.json and send a PR.

(cc @serahrono @pwalsh)