Skip to main content

A toolkit for accessing and working with data from the CRITT Translation Process Research Database (TPR-DB).

Project description

tprdb-utilities

PyPI version Python License: MIT

A Python toolkit for downloading and reading data tables from the CRITT Translation Process Research Database (TPR-DB).

Two functions cover the full workflow:

Function What it does
fetch_TPRDB_tables Downloads study tables from the CRITT API and saves them to a local directory structure
read_TPRDB_tables Reads those tables from a local clone into a single pandas.DataFrame

Installation

# pip
pip install tprdb-utilities

# uv
uv add tprdb-utilities

# poetry
poetry add tprdb-utilities

Quick Start

1 — Download data (fetcher)

Public study (no credentials needed):

from tprdb_utilities import fetch_TPRDB_tables

fetch_TPRDB_tables(
    path="/path/to/local/data",
    StudyID="DG21",
    extensions=["ss", "st"],
    public=True,
)

Private study (requires your TPR-DB username and API token):

from tprdb_utilities import fetch_TPRDB_tables

fetch_TPRDB_tables(
    path="/path/to/local/data",
    StudyID="MYSTUDY",
    extensions=["st"],
    public=False,
    username="myTPRDBusername",   # case-sensitive, must match your account
    token="my-api-token",
)

After downloading, the function always prints a summary like this:

=== fetch_TPRDB_tables Summary ===
StudyID  : DG21
Clone dir: /path/to/local/data/tprdb-mothership-clone
User dir : PUBLIC

Extension  Status            Time
---------  ----------------  ------
kd         Downloaded        1.23s
ss         Downloaded        0.98s

To read these files with read_TPRDB_tables:
  path      = "/path/to/local/data/tprdb-mothership-clone"
  user      = "PUBLIC"
  studies   = ["DG21"]

Copy those argument values directly into read_TPRDB_tables.

Subsequent calls are bandwidth-efficient. When files for an extension are already present, fetch_TPRDB_tables sends the X-Client-Tables-Timestamp header (sourced from the studySummary.xml bundled with the study). The server returns 304 Not Modified when nothing has changed, so no data is transferred. The summary will reflect the outcome:

Extension  Status            Time
---------  ----------------  ------
kd         Up to date (304)  0.21s
ss         Updated           1.05s

2 — Read data (reader)

Use the path and user values printed by fetch_TPRDB_tables at the end of its summary output.

Public study (user="PUBLIC"):

from tprdb_utilities import read_TPRDB_tables

df = read_TPRDB_tables(
    studies=["DG21", "AR22"],
    extension="kd",
    path="/path/to/local/data/tprdb-mothership-clone",
    user="PUBLIC",
)

Private study (user="<your TPR-DB username>"):

from tprdb_utilities import read_TPRDB_tables

df = read_TPRDB_tables(
    studies=["MYSTUDY"],
    extension="kd",
    path="/path/to/local/data/tprdb-mothership-clone",
    user="USER_DIRECTORY_NAME",
)

Directory Structure

fetch_TPRDB_tables creates the following layout under path:

<path>/
└── tprdb-mothership-clone/
    ├── PUBLIC/                  ← public studies
    │   └── <StudyID>/
    │       ├── studySummary.xml
    │       └── Tables/
    │           ├── session1.kd
    │           └── ...
    └── <username>/             ← private studies
        └── <StudyID>/
            ├── studySummary.xml
            └── Tables/
                ├── session1.kd
                └── ...

Each zip response bundles a studySummary.xml file alongside the table files. fetch_TPRDB_tables places it in the <StudyID>/ directory (one level above Tables/) and uses it on subsequent calls to detect whether the server data has changed.

read_TPRDB_tables expects this exact layout, so the two functions are designed to work together seamlessly.


Supported Table Extensions

ag, au, ex, fd, fu, hc, hs, kd, ku, pu, sg, ss, st, tt

License

MIT — see LICENSE.

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

tprdb_utilities-0.2.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

tprdb_utilities-0.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file tprdb_utilities-0.2.0.tar.gz.

File metadata

  • Download URL: tprdb_utilities-0.2.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for tprdb_utilities-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d5b61e21aafa289a69bfa76948c3a6283acb879e8ed765a2a5cdab1c3a2bc27f
MD5 2c87f2094f97bb18aceeebaf54abed55
BLAKE2b-256 dd28382da846de33eca6fcd99aa4b4f22d9c11282a06dfdebbdd5dda76ba798d

See more details on using hashes here.

File details

Details for the file tprdb_utilities-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tprdb_utilities-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4840aa5ce561f2538748ef9f9d12e4b00fdf53c9eb0c48a8ae62f93e71b0d10c
MD5 355d28b9b6fb771964c4ad9c8493f2af
BLAKE2b-256 a88897ee6edcc6747bfba52d44ce534664540db2c4d1e3d27f5713e03cd3dcde

See more details on using hashes here.

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