Converting data

The goal of the data conversion stage is to transform source data downloaded from the infrastructure of the provider into the data model of DBnomics.

Convert script

Example of convert.py script:

#!/usr/bin/env python3

from dbnomics_toolbox.fetcher_utils.cli_utils.convert_cli import ConvertCLI

import abc_fetcher
from abc_fetcher.constants import PROVIDER_METADATA
from abc_fetcher.converter import Converter


def main() -> None:
    cli = ConvertCLI(package_name=abc_fetcher.__name__)
    cli.start()
    converter = Converter(
        **cli.args.as_converter_kwargs,
        provider_metadata=PROVIDER_METADATA,
    )
    converter.start()
    cli.finalize(converter)


if __name__ == "__main__":
    main()

Converter

DatasetConverter

Setting dimensions upfront

(upfront)

Setting dimensions dynamically

(while converting series)

CategoryTreeConverter

Run the convert script

python convert.py source-data converted-data

SDMX