Skip to main content

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


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.3.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

format_flex-0.0.3-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file format_flex-0.0.3.tar.gz.

File metadata

  • Download URL: format_flex-0.0.3.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for format_flex-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0f09a34d80df70b82c452184d2e2ec3805ac9f9c4f29298fb3c50b4d64172eb6
MD5 f2aa5fba0d1d278cd913557bfce3c2e2
BLAKE2b-256 c1a01444bc581023583cb195377c5d444489a431a765242b5ab81f05236fd662

See more details on using hashes here.

File details

Details for the file format_flex-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: format_flex-0.0.3-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

Hashes for format_flex-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8ba7773b6643c8c5189b1faa6cea510e02040ee2def0ca6493d5f6b1ab3d66f2
MD5 7d3e56b6f8e0169c74b44164c748e5f6
BLAKE2b-256 88d2671c9a19787829954f693317537923adcc9875087bc73f3c0238f4e8a8d7

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