Skip to main content

schema-sanitizer

schema-sanitizer turns inconsistent CSV, JSON, JSON Lines, XML, and Parquet data into analytical tables or clean files with a stable schema.

Its native C++23 engine handles reading, inference, reconciliation, and materialization. The Python API adds PyArrow, pandas, Polars, and DuckDB outputs, file writers, cloud access, and partitioned pipelines.

The project is alpha software. Its primary focus is Parquet pipelines and BigQuery external tables.

Index

Install

Install the package with the adapter you need:

pip install "schema-sanitizer[pyarrow]"

Extras are also available for polars, pandas, duckdb, gcs, s3, azure, bigquery, cloud, and all.

First conversion

import schema_sanitizer as ss

result = ss.to_pyarrow(
    "raw/events.jsonl",
    input_format="jsonl",
    parse_integers=True,
    parse_iso_timestamps=True,
)

table = result.clean_data
print(table.schema)
print(result.schema_drifts)

Write directly to Parquet without retaining a complete table in memory:

ss.to_parquet(
    "raw/events.jsonl",
    "silver/events.parquet",
    input_format="jsonl",
    multi_threading=True,
)

Every conversion returns a Result containing the output, statistics, execution policy, schema registry, and detected schema changes.

What it does

  • Reads CSV, JSON, JSON arrays, JSONL/NDJSON, XML, Parquet, and Python dictionary iterables.
  • Processes individual files, non-recursive directories, and remote objects.
  • Produces PyArrow, pandas, Polars, DuckDB, CSV, JSONL, or Parquet.
  • Carries a schema registry across runs and reports every schema change.
  • Reconciles reordered or additive CSV headers.
  • Uses one global memory limit and adapts concurrency to the machine.
  • Supports local paths, GCS, S3, Azure Blob, and HTTP(S) files.
  • Builds Parquet pipelines from Hive partitions or object modification times.
  • Generates and maintains BigQuery external tables and schema sidecars.

Two ways to use the API

The to_* functions are convenient for one-off calls. Create a Sanitizer to reuse one configuration:

sanitizer = ss.Sanitizer(
    ss.SanitizeOptions(
        input_format="csv",
        csv=ss.CsvOptions(header_mode="union"),
        parsing=ss.ParsingOptions(iso_dates=True),
        resources=ss.ResourceOptions(
            multi_threading=True,
            memory_limit_bytes=512 * 1024 * 1024,
        ),
    )
)

frame = sanitizer.to_polars("raw/daily/").clean_data

Schema and memory

Pass one run's registry to the next to evolve the schema deterministically:

first = ss.to_parquet(
    "raw/day-1.jsonl",
    "silver/day-1.parquet",
    input_format="jsonl",
)
second = ss.to_parquet(
    "raw/day-2.jsonl",
    "silver/day-2.parquet",
    input_format="jsonl",
    schema_registry=first.schema_registry,
)

memory_limit_bytes bounds resources owned by the conversion. Streaming readers and writers can process files larger than that budget. A returned analytical table or DataFrame becomes caller-owned and is outside the budget; direct file output is the safe choice when a complete result may be too large.

Documentation

The documentation guide organizes detailed material by task:

Complete programs live in examples/. Example 7 covers a Hive pipeline to Parquet and BigQuery. Example 8 covers CSV under a flat GCS prefix, modification-time windows, a custom Polars transformation, and UTC year/month/day Hive output from a chosen timestamp.

Development

python -m pip install -e ".[dev]"
pytest -q
pre-commit run --all-files

See the development guide for native builds, focused tests, benchmarks, and CI.

License

Apache License 2.0. See LICENSE.

Release files for schema-sanitizer 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schema-sanitizer 0.4.1
File Size Uploaded
schema_sanitizer-0.4.1.tar.gz 1.7 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for schema-sanitizer 0.4.1
File
schema_sanitizer-0.4.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
schema_sanitizer-0.4.1-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
schema_sanitizer-0.4.1-cp311-abi3-macosx_11_0_x86_64.whl CPython 3.11 abi3 macOS 11.0+ x86-64 Details
schema_sanitizer-0.4.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 10.2 MB

Release files / schema_sanitizer-0.4.1.tar.gz

Download URL schema_sanitizer-0.4.1.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
79482ce667a4bc51ddc87239d39f693444dbcb464263076fdd693844f3c14ce8
BLAKE2b-256 checksum
How to use checksums
93ce5543b9e952aca417a3d09fa66e93fbb7fbdb18be294983f59d17056b68b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / schema_sanitizer-0.4.1-cp311-abi3-win_amd64.whl

Download URL schema_sanitizer-0.4.1-cp311-abi3-win_amd64.whl
Size 2.1 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e35be8f0722ca2c0fb6c3315f1f83ae3f51817ecacd00862e62d64f0728ed83d
BLAKE2b-256 checksum
How to use checksums
e93ba27681bac9171cc7448a796d6c3263ef77ec87770a8264bbdea0975cf3f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / schema_sanitizer-0.4.1-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL schema_sanitizer-0.4.1-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
15e5607b55fb76c538c08429a7d35a5cdbf933ce6afa7c8bd57622ebbdc2fc6a
BLAKE2b-256 checksum
How to use checksums
6a16e6f5becf189531e34e0208363cd4ea58cb8acaa7006eebddda95da029e78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / schema_sanitizer-0.4.1-cp311-abi3-macosx_11_0_x86_64.whl

Download URL schema_sanitizer-0.4.1-cp311-abi3-macosx_11_0_x86_64.whl
Size 2.1 MB
Tags CPython 3.11 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
5592f08b5f270e0878799af0e1c8beaee8305c75bd7a982498f623003220bcf7
BLAKE2b-256 checksum
How to use checksums
fd9418865b95edcb60a9e07d425e896f8b26da5bebf1a20238821774cb9e2abc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / schema_sanitizer-0.4.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL schema_sanitizer-0.4.1-cp311-abi3-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8311460400dad785bade45fdb1d7674ba8ee7c3c8b223b980ca826cbd461943c
BLAKE2b-256 checksum
How to use checksums
9b87b290c91e63e86ab722969deb29514e3bb5780aaac69d9611ff3c25d2ccf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.2

5 release files

This release

0.4.1 This release

5 release files

0.4.0

5 release files

0.3.9

5 release files

0.3.8

5 release files

0.3.7

5 release files

0.3.6

5 release files

0.3.5

5 release files

0.3.4

5 release files

0.3.3

5 release files

0.3.2

5 release files

0.3.1

5 release files

0.3.0

5 release files

0.2.9

5 release files

0.2.8

5 release files

0.2.6

5 release files

0.2.5

5 release files

0.2.4

5 release files

0.2.3

5 release files

0.2.2

5 release files

0.2.1

5 release files

0.2.0

5 release files

0.1.9

5 release files

0.1.8

5 release files

0.1.7

5 release files

0.1.6

5 release files

0.1.5

5 release files

0.1.4

5 release files

0.1.3

5 release files

0.1.2

5 release files

0.1.1

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page