Skip to main content

xphyle: extraordinarily simple file handling

PyPI Travis CI Coverage Status Codacy Badge Documentation Status DOI JOSS

logo

xphyle is a small python library that makes it easy to open compressed files. Most importantly, xphyle will use the appropriate program (e.g. 'gzip') to compress/decompress a file if it is available on your system; this is almost always faster than using the corresponding python library. xphyle also provides methods that simplify common file I/O operations.

Recent version of xphyle (4.0.0+) require python 3.6. Older versions of xphyle support python 3.4+.

Please note that xphyle may work on Windows, but it is not tested.

Installation

pip install xphyle

Building from source

Clone this repository and run

make

Example usages:

from xphyle import *
from xphyle.paths import STDIN, STDOUT

# Open a compressed file...
myfile = xopen('infile.gz')

# ...or a compressed stream
# e.g. gzip -c afile | python my_program.py
stdin = xopen(STDIN)

# Easily write to the stdin of a subprocess
with open_('|cat', 'wt') as process:
    process.write('foo')

# We have to tell xopen what kind of compression
# to use when writing to stdout
stdout = xopen(STDOUT, compression='gz')

# The `open_` method ensures that the file is usable with the `with` keyword.
# Print all lines in a compressed file...
with open_('infile.gz') as myfile:
    for line in myfile:
        print(line)

# ... or a compressed URL
with open_('http://foo.com/myfile.gz') as myfile:
    for line in myfile:
        print(line)

# Transparently handle paths and file objects
def dostuff(path_or_file):
    with open_(path_or_file) as myfile:
        for line in myfile:
            print(line)

# Read all lines in a compressed file into a list
from xphyle.utils import read_lines
lines = list(read_lines('infile.gz'))

# Sum the rows in a compressed file where each line is an integer value
total = sum(read_lines('infile.gz', convert=int))

See the Documentation for full usage information.

Supported compression formats

  • gzip (uses igzip or pigz if available)
  • bgzip
  • bzip2 (uses pbzip2 if available)
  • lzma
  • zstd

Issues

Please report bugs and request enhancements using the issue tracker.

Roadmap

Future releases are mapped out using GitHub Projects.

Citing xphyle

Didion, JP (2017) xphyle: Extraordinarily simple file handling. Journal of Open Source Software; doi:10.21105/joss.00255

Acknowledgements

Metadata

Release files for xphyle 4.4.4

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

Source distribution (sdist)

Source distribution for xphyle 4.4.4
File Size Uploaded
xphyle-4.4.4.tar.gz 1.4 MB Details

Built distribution (wheel)

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

Total release size: 1.4 MB

Release files / xphyle-4.4.4.tar.gz

Download URL xphyle-4.4.4.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
2ec69c1e795d0c35ecc0a4572cb1eb6647b79d0f8746646cd3f6159c33e2ce2c
BLAKE2b-256 checksum
How to use checksums
73497e55ce45b42c91727638e549a8be400606cd1057b0aee0e28b1fffa6b30f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / xphyle-4.4.4-py3-none-any.whl

Download URL xphyle-4.4.4-py3-none-any.whl
Size 58.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
229accb765621e09b48f67627a46939a902bf26a67338a03d6d20689e78653d2
BLAKE2b-256 checksum
How to use checksums
a274c17f17b6783651497027d0eee83dcda252657e0a0b1a9f9baf870e5a748d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

4.4.4 This release

2 release files

4.4.2

3 release files

4.4.1

3 release files

4.4.0

3 release files

4.3.0

3 release files

4.2.2

3 release files

4.2.1

3 release files

4.2.0

3 release files

4.1.3

3 release files

4.1.2

3 release files

4.1.1

3 release files

4.1.0

3 release files

4.0.8

3 release files

4.0.7

3 release files

4.0.6

1 release file

4.0.5

3 release files

4.0.4

1 release file

4.0.3

1 release file

4.0.2

1 release file

4.0.1

1 release file

4.0.0

1 release file

3.1.6

1 release file

3.1.5

1 release file

3.1.4

1 release file

3.1.3

1 release file

3.1.2

1 release file

3.1.1

1 release file

3.1.0

1 release file

3.0.6

1 release file

3.0.5

1 release file

3.0.4

1 release file

3.0.3

1 release file

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.2.3

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.0

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.21

1 release file

1.0.0

1 release file

0.7.11

1 release file

0.7.8

1 release file

0.7.7

1 release file

0.7.6

1 release file

0.7.5

1 release file

0.7.4

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

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