Skip to main content

autoopen

autoopen is a small drop-in replacement for the most common use cases of Python’s built-in open() function that will automatically handle compressed files based on the filename.

Usage

For example:

from autoopen import autoopen

filename = "example.txt.xz"
with autoopen(filename, "rt", encoding="utf-8") as file:
    contents = file.read()

autoopen will check the given filename’s last suffix. If it indicates one of the supported compressors, the corresponding compressor or decompressor will be used, otherwise it falls back to built-in open.

Support for .gz, .bz2, .xz, .lzma, and .zst/.zstd is built-in (the latter requires the python-zstandard package). The special filename - indicates reading from stdin or writing to stdout.

Release files for autoopen 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autoopen 0.1.0
File Size Uploaded
autoopen-0.1.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autoopen 0.1.0
File Interpreter ABI Platform
autoopen-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / autoopen-0.1.0.tar.gz

Download URL autoopen-0.1.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
771a62070ec5c9cc850209e278e2467c24bf2564a1426f300ab9b1da2add5186
BLAKE2b-256 checksum
How to use checksums
fafab81af60c4111ce7e81cbc3419edda5eae292aa9df5b547e39aa8836b6457
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Linux/5.17.0-1-amd64

Release files / autoopen-0.1.0-py3-none-any.whl

Download URL autoopen-0.1.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0b5f2d7d399f5b1801aa150aef90d883b3d83d3fa7adabc245068d5da8dbef4
BLAKE2b-256 checksum
How to use checksums
bcc1b668950a45e8a13569f37bdc0589a9346f64e533e0a09c838ac5a5264d7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Linux/5.17.0-1-amd64

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page