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 to_* 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.2

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.2
File Size Uploaded
schema_sanitizer-0.4.2.tar.gz 2.2 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for schema-sanitizer 0.4.2
File
schema_sanitizer-0.4.2-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
schema_sanitizer-0.4.2-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.2-cp311-abi3-macosx_11_0_x86_64.whl CPython 3.11 abi3 macOS 11.0+ x86-64 Details
schema_sanitizer-0.4.2-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details

Total release size: 12.1 MB

Release files / schema_sanitizer-0.4.2.tar.gz

Download URL schema_sanitizer-0.4.2.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
49d396b5dcb37f21960b6fa7fe6660c8459324552d74cbfc616ff6a395ed8e6d
BLAKE2b-256 checksum
How to use checksums
f2924cf2163a500e0315f8b38eb571252242b9e14ec1f6e4fc6ea9efcca9403e
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 13, 2026.

Transparency log

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

Download URL schema_sanitizer-0.4.2-cp311-abi3-win_amd64.whl
Size 2.4 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2f4015e8c5547352b80bc6327dca907749e25067dec9d08f24f936de46429770
BLAKE2b-256 checksum
How to use checksums
1419212210ecdf95118ad8d3b229416f8f24a3cf40d60225bb8095bd89801c60
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 13, 2026.

Transparency log

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

Download URL schema_sanitizer-0.4.2-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.8 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
20148b24bd66d35b8520c2cc01632f46fc854cd89a77fab4acc4b01b48c888ee
BLAKE2b-256 checksum
How to use checksums
8b66f02800654f5b37ac10aa252ab6fd5b660f817697f87baa22c678ba776378
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 13, 2026.

Transparency log

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

Download URL schema_sanitizer-0.4.2-cp311-abi3-macosx_11_0_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
fe4d43e1d9a81dfe122414e6ca6bb842c78476aec9c0f18aa1d782edccae42b0
BLAKE2b-256 checksum
How to use checksums
ff944e4d2820a6c7697addcafe1547e1fa7a9744c12a5f2473f8315e595c71e1
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 13, 2026.

Transparency log

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

Download URL schema_sanitizer-0.4.2-cp311-abi3-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0462541a64415e349435706a4ae62b52158952f1c8c6a0ec47a9290899a3d40d
BLAKE2b-256 checksum
How to use checksums
95ca54c6c06f3671eace62a120822de269ad7266c6adcd59f538b7f47e549660
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 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.2 This release

5 release files

0.4.1

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