A flexible Python library for easy handling and conversion of Hierarchical, Tabular, and Serialized data formats.
Project description
FormatFlex
FormatFlex is a flexible Python library designed to seamlessly handle various text and data formats.
Supported Data Formats
Hierarchical Data (HData)
- XML
- JSON
- YAML
- TOML
- CBOR2
- MSGPACK
- BSON
- UBJSON
Tabular Data (TData)
- CSV
- Excel
- Parquet
- ORC
- Feather
- HDF5
Serialization (GData)
- Pickle
- Dill
- Cloudpickle
- Joblib
Installation
pip install format_flex
Usage
Hierarchical Data Example (HData)
from format_flex import HData
with open("sample/sample.json", "rt", encoding="utf-8") as f:
data = f.read()
hdata = HData(data)
save_path = "./output/hdata_example"
# Convert and save in various formats
print(hdata.to.xml(save_path).summary)
print(hdata.to.json(save_path).summary)
print(hdata.to.yaml(save_path).summary)
print(hdata.to.toml(save_path).summary)
print(hdata.to.bson(save_path).summary)
print(hdata.to.cbor2(save_path).summary)
print(hdata.to.msgpack(save_path).summary)
print(hdata.to.ubjson(save_path).summary)
Tabular Data Example (TData)
from format_flex import TData
tdata = TData("sample/music_dataset.csv")
save_path = "./output/tdata_example"
print(tdata.to.csv(save_path).summary)
print(tdata.to.excel(save_path).summary)
print(tdata.to.parquet(save_path).summary)
print(tdata.to.orc(save_path).summary)
print(tdata.to.feather(save_path).summary)
print(tdata.to.hdf5(save_path).summary)
Serialization Example (GData)
import numpy as np
from format_flex import GData
data = {
"name": "Alice",
"age": 30,
"scores": [95, 87, 78],
"numbers": np.random.random((10, 10)),
"details": {
"hobbies": ["reading", "cycling", "hiking"],
"active": True,
"balance": 1234.56
}
}
save_path = "./output/gdata_example"
gdata = GData(data)
print(gdata.to.pickle(save_path).summary)
print(gdata.to.dill(save_path).summary)
print(gdata.to.cloudpickle(save_path).summary)
print(gdata.to.joblib(save_path).summary)
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
format_flex-0.0.2.tar.gz
(9.5 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 format_flex-0.0.2.tar.gz.
File metadata
- Download URL: format_flex-0.0.2.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f224bf94dcfaa6d9f75f3c3d8fd3338ef017e7ea167c499f63cd55e5d629d100
|
|
| MD5 |
adb4616f2106fd42e692d6ee496980a1
|
|
| BLAKE2b-256 |
7180dca8c62c6db6438d2be7c4b68ce1d1d8cc3e6defdce93e75b7100b6c1bc4
|
File details
Details for the file format_flex-0.0.2-py3-none-any.whl.
File metadata
- Download URL: format_flex-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b8be108e4aac61ad1f9dcab8ec6e0b93f24e4f5ddd6294bd78274cc2e1223e4
|
|
| MD5 |
41b05ab73c83d460bddc4c749f32d059
|
|
| BLAKE2b-256 |
1047681f79ade2a14a1a685f47b2867d668a63f535d37f2add35146dfa1c8244
|