Skip to main content
Help us improve Python packaging – donate today!

Utilities for working with files.

Project Description

https://pypi.python.org/pypi/xphyle https://travis-ci.org/jdidion/xphyle Coverage Status Codacy Badge Documentation Status

xphyle: extraordinarily simple file handling

xphyle is a small python (3.3+) library that makes it easy to open compressed files. Most importantly, xphyle will use the appropriate program (e.g. ‘gzip’) to compress/uncompress 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.

Installation

pip install xphyle

If you are using python 3.3 or 3.4, this will install one dependency: backports.typing.

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')

# 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.

Roadmap

Future releases are mapped out using GitHub Projects.

Developers

We welcome any contributions via pull requests. Style-wise, we try to adhere to the Google python style guidelines. We use Google-style docstrings, which are formatted by the Napoleon Sphinx Plugin. We run pylint as part of each build and strive to maintain a 10/10 score. However, we disable some pylint checks:

  • Function annotations: pylint does not properly handle whitespace around function annotations (https://github.com/PyCQA/pylint/issues/238).
  • White space on empty lines: we use white space as a visual guide to the structure of the code. Each blank line should have whitespace matching the indent level of the next non-blank line.
  • Checks that are arbitrary/overly restrictive (e.g. ‘too-many-xxx’; see .pylintrc for full list)

Release history Release notifications

History Node

4.0.0rc0

History Node

3.1.6

History Node

3.1.5

History Node

3.1.4

History Node

3.1.3

History Node

3.1.2

History Node

3.1.1

History Node

3.1.0

History Node

3.0.6

History Node

3.0.5

History Node

3.0.4

History Node

3.0.3

History Node

3.0.2

History Node

3.0.1

History Node

3.0.0

History Node

2.2.3

History Node

2.2.1

This version
History Node

2.2.0

History Node

2.1.1

History Node

2.1.0

History Node

2.0.0

History Node

1.1.5

History Node

1.1.4

History Node

1.1.3

History Node

1.1.2

History Node

1.1.1

History Node

1.1.0

History Node

1.0.21

History Node

1.0.0

History Node

0.7.11

History Node

0.7.8

History Node

0.7.7

History Node

0.7.6

History Node

0.7.5

History Node

0.7.4

History Node

0.7.3

History Node

0.7.2

History Node

0.7.1

History Node

0.7.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
xphyle-2.2.0.tar.gz (753.5 kB) Copy SHA256 hash SHA256 Source None Feb 17, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page