A Python package to convert tabular data and metadata into CDISC Dataset-JSON v1.1 format.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
README.md
Project: dsjson
A lightweight Python package to convert clinical tabular datasets (e.g., SDTM/ADaM) and metadata into CDISC Dataset-JSON v1.1 format. It supports multiple metadata input formats including CSV, Excel, JSON, and XML (planned). If you don't have a specific column metadata file the it can also extracts variable label from specification file and create column metadata.
The CDISC Dataset-JSON standard is essential for regulatory submissions and data sharing in the clinical trial industry. This package simplifies the process of creating compliant JSON files from common data formats like CSV or pandas DataFrames, saving developers time and reducing the risk of manual errors.
Features
- Converts
DataFrame+ column metadata to Dataset-JSON v1.1 - Supports CSV, Excel, JSON for metadata
- Auto-generates
datasetJSONCreationDateTime - Enforces required top-level metadata
- Extract Variable Label from Specification file
- Converts extracted Variable Label into column metadata
- loads a Dataset-JSON file into a pandas DataFrame and attaches the top-level metadata to the DataFrame's attrs attribute.
Installation
pip install dsjson
Quick Start
from dsjson import load_metadata, to_dataset_json, extract_labels, make_column_metedata
import pandas as pd
my_excel_path = r"specification path"
# Load data
rows = pd.read_csv("examples/vs.csv")
# Extract variables from specification and convereted that to column metadata
variable_labels = extract_labels(spec_path=my_excel_path, sheet_name="DM", variable_name_col="Variable Name", variable_label_col="Variable Label")
columns = make_column_metadata(df=data_df, variable_labels=variable_labels, domain="DM")
# this can be used where we already have column metadata already defined in a file - if you make column metadata as per above code, then this is not required
columns = load_metadata("examples/columns_vs.csv", file_type="csv")
# Create Dataset-JSON
ds = to_dataset_json(
data_df=rows,
columns_df=columns,
name="VS",
label="Vital Signs",
itemGroupOID="IG.VS",
originator="My CRO",
sourceSystem_name="Python",
sourceSystem_version="3.10",
fileOID="F.VS.001",
studyOID="S.1234"
)
# loads a Dataset-JSON file into a pandas DataFrame and attaches the top-level metadata to the DataFrame's attrs attribute.
vs_df = read_dataset_json("examples/vs.json")
# Access the attached metadata from the .attrs attribute
print(f"File OID: {vs_df.attrs.get('fileOID')}")
print(f"Originator: {vs_df.attrs.get('originator')}")
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsjson-1.3.tar.gz.
File metadata
- Download URL: dsjson-1.3.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10f08f22e239776a0df6e1f7444087a16a77a80f0c4efc587dda21f25b37e50a
|
|
| MD5 |
7cdca93838cb4fee8fae5d43e7d6959d
|
|
| BLAKE2b-256 |
c651824c096e2b9c62e42f44e3551a95e9dec42a851459d6829e5a2a791843c2
|
File details
Details for the file dsjson-1.3-py3-none-any.whl.
File metadata
- Download URL: dsjson-1.3-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a760a84f1b1ef5d8f9f3468b15b16e878cf5136a0f48bc7c123004ae2412710e
|
|
| MD5 |
3c4bb0b2991d44efd39b60daf900c8d5
|
|
| BLAKE2b-256 |
a11bb17c1659fd0f590e4f58c3fec212ce2fdc13c91a01dc4b088a8a1de7cc48
|