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(source, sample_size=None) -> Schema

  • source: File path, DataFrame, Arrow Table, or file-like object.
  • sample_size: optional max records to smple.

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.3.tar.gz (11.5 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.3-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for schemarize-0.1.3.tar.gz
Algorithm Hash digest
SHA256 457ccd596e2f7e82d290a0f82c6aab8fab8e7ff6dcb3b7856dbdcc693f462a95
MD5 5e6047d0730e3ac6a7b9ea4c4a7ef41d
BLAKE2b-256 632a15cc3bb7e02e41dc89a7d486bedae1d5225fc01cf9acc025aabd6065e85a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for schemarize-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f8011be181ed5eaf174b3934fe0e10fb401123f6fa1759fb35f44037ceaf27d9
MD5 0fe1d8bf5410324ea24cf9c7a1459898
BLAKE2b-256 18b1951ee883e0a4238842605743eb0d3f18694801095221f4ba841a13bc49d3

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