Skip to main content

A toolkit to infer data schemas from samples

Project description

Schemarize

Schemarize is a Python package to infer, inspect, and serialize the schema of data files and objects—whether they’re JSON, CSV, Parquet, or DataFrames. It’s designed for simplicity: just call one method, get a schema, and export as JSON, YAML, or CSV.

GITHUB

Installation

Install from PyPI:

pip install schemarize

Quickstart

import pandas as pd
from schemarize import schemarize

df = pd.DataFrame({"a": [1, 2], "b": ["x", "y"]})
schema = schemarize(df)

print(schema.to_json())
print(schema.to_yaml())
print(schema.to_csv())

schema.save("my_schema.json")   # or .yaml, .csv

You can also pass a file path (CSV, JSON, Parquet, etc.):

schema = schemarize("data.csv")
print(schema.to_dict())

Main Function

schemarize(data, *, output="json", sample_size=None) -> Schema

  • data: File path, DataFrame, Arrow Table, or file-like object.
  • output: "json", "yaml", or "csv" (for future use; .to_*() preferred).
  • sample_size: Optionally limit number of records to inspect.

Returns a Schema object.


Schema Methods

The returned Schema object provides:

  • to_dict() – Return the schema as a Python dict.
  • to_json(pretty=True) – Serialize as JSON string.
  • to_yaml() – Serialize as YAML string.
  • to_csv() – Serialize as CSV string.
  • save(path, format=None) – Save to file, format auto-detected by extension.

Example: Saving a schema

schema.save("my_schema.yaml")
schema.save("my_schema.csv")

Supported Inputs

  • Pandas DataFrames
  • PyArrow Tables
  • File paths: CSV, JSON, JSONL, Parquet (compressed files supported)
  • File-like objects

Supported Outputs

  • JSON
  • YAML (requires pyyaml)
  • CSV (flat field view)

License

MIT


Links

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

schemarize-0.1.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

schemarize-0.1.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file schemarize-0.1.2.tar.gz.

File metadata

  • Download URL: schemarize-0.1.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for schemarize-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4ddab3a9664a3bb866c79c3f4aa561c72c2f6717f4e794c55405e66cb21c3c08
MD5 39078d50dece5dca06ae1b0122295386
BLAKE2b-256 8d7199bb2d3487f5c1ce0dc64378ce40892e1bf8f5a585426954fa0bafa11417

See more details on using hashes here.

File details

Details for the file schemarize-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: schemarize-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for schemarize-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b5064dd97ea0fd7b631435ac5c09bbc3b10029c07161ab895f40abbd16d8c9b6
MD5 90377c3312ce0316d04d7a8c5d152a99
BLAKE2b-256 ed0fda1e699a955ff55dc9b33d88eea756fc105a150fa56d0c249e82885e5483

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