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. [https://github.com/jasonxfrazier/schemarize]
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
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.1.tar.gz
(11.7 kB
view details)
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 schemarize-0.1.1.tar.gz.
File metadata
- Download URL: schemarize-0.1.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ed2d37ecf572150675bce4ff4d010de06c143e3dc42cc1d87305ab7e99a4005
|
|
| MD5 |
c3bfd2afafd510940bbc2b8ba352c004
|
|
| BLAKE2b-256 |
119a8c2a2b6557cd02be36844602bd5b44d41aacf298a2357d55fec1332d2c0f
|
File details
Details for the file schemarize-0.1.1-py3-none-any.whl.
File metadata
- Download URL: schemarize-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
888f079ea3ceb73bbbe447c0c8e3ff3c4bab84e8b7d7a34e254b28542d2c0b36
|
|
| MD5 |
3bdd0c24202cd92c6beeab28151117a6
|
|
| BLAKE2b-256 |
1321f18c5ee9dfde17e6a67c6ef3b7b38df958ad7124d7f4e60ffe928d7fc047
|