Tools for generating CSV and other flat versions of the structured data


License
MIT
Install
pip install flattentool==0.24.1

Documentation

Flatten-Tool [Beta]

Build Status Coverage Status Code Health License: MIT Documentation Status

Flatten-Tool is a general purpose tool with the goal of allowing a dataset to be round-tripped between structured JSON and tabular data packages or spreadsheets: providing a bridge between richly structured datasets and accessible flat formats.

It was developed for use with the Open Contracting Data Standard, and has been further developed with the 360 Giving Data Standard. We're keen to see if it is useful in other contexts too.

It is also used in to power the COnvert Validate Explore (COVE) tool which provides a web interface for Flatten-Tool configured against a particular JSON Schema.

For more information see the Flatten-Tool docs.

Features

  • Convert data from a "flat" spreadsheet into structured form;
  • Take JSON data and provide a flattened output;
  • Generate a template Excel or CSV file based on a JSON Schema;
  • Use a JSON schema to guide the approach to flattening;
  • Use a JSON schema to provide column titles rather than field names;

For more information see the Flatten-Tool docs.

Quick Example

For more examples see http://flatten-tool.readthedocs.io/en/latest/examples/

{
    "main": [
        {
            "id": "1",
            "a": [
                {
                    "b": "2",
                    "c": "3"
                },
                {
                    "b": "4",
                    "c": "5"
                }
            ],
            "d": "6"
        },
        {
            "id": "7",
            "a": [
                {
                    "b": "8",
                    "c": "9"
                },
                {
                    "b": "10",
                    "c": "11"
                }
            ],
            "d": "12"
        }
    ]
}

Can be converted to/from these spreadsheets:

id d
1 6
7 12
id a/0/b a/0/c
1 2 3
1 4 5
7 8 9
7 10 11

For more examples see http://flatten-tool.readthedocs.io/en/latest/examples/