Skip to main content

Unified I/O interface for Python

Project description

PyPI version License: MIT

⚡️ Introduction

unified-io is a Python utility that attempts to unify several I/O operations (i.e., read/write data in different formats) under a similar interface while making them more concise and user-friendly.

The library provides a unified interface for reading/writing files, which is based on the following principles:

  • Read/write interfaces consist of concise functions with similar signatures.
  • Read/write interfaces allows passing keyword arguments to the underlying I/O functions to preserve flexibility.
  • Read operations can be performed lazily using generators.
  • Before reading/writing, the user can specify a callback function that will be applied to each element of the data stream.
  • read functions have load aliases (e.g., read_csv has a load_csv alias) and write functions have save aliases (e.g., write_csv has a save_csv alias.
  • Use very efficient stuff for each format (e.g., orjson for json files). Suggestions are welcome!

✨ Supported formats

🔌 Requirements

python>=3.7

💾 Installation

pip install unified-io

💡 Examples

The API is designed to be as simple as possible. For example, the following code snippet reads a CSV file, applies a callback function to each element of the data stream, and writes the result to a JSONl file:

from unified_io import read_csv, write_jsonl

def callback(x):
    return {"id": x["id"], "title": x["title"].lower()}

# Using a generator we avoid loading the entire file into memory
data = read_csv('input.csv', callback=callback, generator=True)

write_jsonl('output.jsonl', data)

📚 Documentation

Browse the documentation for more details and examples.

🎁 Feature Requests

Would you like to see other features implemented? Please, open a feature request.

🤘 Want to contribute?

Would you like to contribute? Please, drop me an e-mail.

📄 License

unified-io is an open-sourced software 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

unified_io-0.1.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unified_io-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 57a6aad60017baab4d162b85a9c12ae4b2cbc278e21c3437d14f75b3940e51ab
MD5 945cf2788e5180cf0ea5b9a2768a4770
BLAKE2b-256 be7ef248f5b0e106c58b49cd5fa171112cad2a33cad1692b20961f7b11543284

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