Skip to main content

Another data transformation language

Project description

adtl – another data transformation language

Python 3.9+

tests codecov Code style: black

adtl is a data transformation language (DTL) used by some applications in Global.health, notably for the ISARIC clinical data pipeline at globaldothealth/isaric and the InsightBoard project dashboard at globaldothealth/InsightBoard

Documentation: ReadTheDocs

Installation

You can install this package using either pipx or pip. Installing via pipx offers advantages if you want to just use the adtl tool standalone from the command line, as it isolates the Python package dependencies in a virtual environment. On the other hand, pip installs packages to the global environment which is generally not recommended as it can interfere with other packages on your system.

  • Installation via pipx:

    pipx install adtl
    
  • Installation via pip:

    python3 -m pip install adtl
    

If you are writing code which depends on adtl (instead of using the command-line program), then it is best to add a dependency on adtl to your Python build tool of choice.

To use the development version, replace adtl with the full GitHub URL:

pip install git+https://github.com/globaldothealth/adtl

Rationale

Most existing data transformation languages are usually in a XML dialect, though there are recent variations in other file formats. In addition, many DTLs use a custom domain specific language. The primary utility of this DTL is to provide a easy to use library in Python for basic data transformations, which are specified in a JSON file. It is not meant to be a comprehensive, and adtl can be used as a step within a larger data processing pipeline.

Usage

adtl can be used from the command line or as a Python library

As a CLI:

adtl specification-file input-file

Here specification-file is the parser specification (as TOML or JSON) and input-file is the data file (not the data dictionary) that adtl will transform using the instructions in the specification.

If adtl is not in your PATH, this may give an error. Either add the location where the adtl script is installed to your PATH, or try running adtl as a module

python3 -m adtl specification-file input-file

Running adtl will create output files with the name of the parser, suffixed with table names in the current working directory.

Python library:

import adtl

parser = adtl.Parser(specification)
print(parser.tables) # list of tables created

for row in parser.parse().read_table(table):
    print(row)

alternatively to get an output file as a CSV, similarly to the CLI:

import adtl

data = adtl.parse("specification-file", "input-file")

where data is returned as a dictionary of pandas dataframes, one for each table.

Development

Install pre-commit and setup pre-commit hooks (pre-commit install) which will do linting checks before commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adtl-0.11.0.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adtl-0.11.0-py3-none-any.whl (59.2 kB view details)

Uploaded Python 3

File details

Details for the file adtl-0.11.0.tar.gz.

File metadata

  • Download URL: adtl-0.11.0.tar.gz
  • Upload date:
  • Size: 48.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for adtl-0.11.0.tar.gz
Algorithm Hash digest
SHA256 7ab0e7a8c279387290e678987b7673a09ec3b41d96ffca785b2cac16d52e6b23
MD5 56069ac0d9cb01c8362c1a0bd995d6f4
BLAKE2b-256 a7fb4e6d762144ea1f7c47117b034bd78cbb7c3348b223ce21d5938c3e0f168b

See more details on using hashes here.

Provenance

The following attestation bundles were made for adtl-0.11.0.tar.gz:

Publisher: publish.yml on globaldothealth/adtl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adtl-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: adtl-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 59.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for adtl-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3425b94ac9b69266e77cd976af96a2b5446f0ab4bfe09b427d670edfbcc833b2
MD5 92824cbdae77325c00dd991ba81289ff
BLAKE2b-256 f219a3a5ebac65af4561b0ba9e4ab49ef4a724d6414c27df185d35a1d47ed1eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for adtl-0.11.0-py3-none-any.whl:

Publisher: publish.yml on globaldothealth/adtl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page