Skip to main content

Easy data input/output utilities.

Project description

pyeio | pypi

  • Description: Drop-in replacement for standard io module with some extra utilities.
  • Purpose: Solves having to constantly with open stuff.
  • Notes: Full docs may be added at some later point, along with some other file formats perhaps.

Install

pip install pyeio

or

uv add pyeio

Usage

import pyeio as io

Everything should work the same as io, but with the following additions:

Extra IO Functions

io.read

Read file content as string (utf-8) or bytes.

# Read as string (default)
content = io.read("file.txt")

# Read as bytes
data = io.read("file.bin", bytes)

io.write

Write string or bytes to a file. Raises an error if the file already exists unless overwrite=True.

# Write string
io.write("file.txt", "Hello, world!")

# Write bytes
io.write("file.bin", b"\x00\x01\x02")

# Overwrite existing file
io.write("file.txt", "New content", overwrite=True)

io.append

Append string or bytes to the end of a file.

# Append string
io.append("file.txt", "\nAnother line")

# Append bytes
io.append("file.bin", b"\x03\x04")

Formats

Additionally, json, toml, and yaml are included, with overloads/generics for handling pydantic models. Each of these exposes a read, and write function which more or less works the exact same way, along with a parse and serialize function.

Here are some examples:

# Read JSON file
data = io.json.read("config.json")

# Read JSON file into a Pydantic model
user = io.json.read("user.json", UserModel)

# Write JSON to file
io.json.write("output.json", {"key": "value"})

# Write with pretty printing
io.json.write("output.json", data, overwrite=True, indent=True)

# Parse JSON string/bytes
data = io.json.parse('{"key": "value"}')
user = io.json.parse(json_bytes, UserModel)

# Serialize to string/bytes
json_bytes = io.json.serialize(data)  # returns bytes by default
json_str = io.json.serialize(data, str)

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

pyeio-0.2.2.tar.gz (106.1 kB view details)

Uploaded Source

Built Distribution

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

pyeio-0.2.2-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file pyeio-0.2.2.tar.gz.

File metadata

  • Download URL: pyeio-0.2.2.tar.gz
  • Upload date:
  • Size: 106.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.4

File hashes

Hashes for pyeio-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f587b6c52514cd660fb0ce53ac4c024af208c342e66274808a0bf87d7d8f09e9
MD5 cfef5fe6c39be41b0f298d408b3f1bf3
BLAKE2b-256 76d9398bbcb824b4890208bda582022dc1d1090125c96b585c6a03ab89245a3d

See more details on using hashes here.

File details

Details for the file pyeio-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pyeio-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.4

File hashes

Hashes for pyeio-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a4def492aef23b45cc3cfa71307b8c879161cf044e7be7ef9567e3ae6f504fa0
MD5 422696a5fb360ede8f089b53cb38fe1a
BLAKE2b-256 da832c017cb467d366e2b78032d5a3c6574d21bdeedab38f996ff7eb0e5d2f60

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