Skip to main content

Memory efficient way of reading files line-by-line from the end of file

Project description

file_read_backwards

https://img.shields.io/pypi/v/file_read_backwards.svg https://img.shields.io/travis/robin81/file_read_backwards.svg?branch=master Documentation Status Updates

Memory efficient way of reading files line-by-line from the end of file

Features

This package is for reading file backward line by line as unicode in a memory efficient manner for both Python 2.7 and Python 3.

It currently supports ascii, latin-1, and utf-8 encodings.

It supports “\r”, “\r\n”, and “\n” as new lines.

Usage Examples

An example of using file_read_backwards for python2.7:

#!/usr/bin/env python2.7

from file_read_backwards import FileReadBackwards

f = FileReadBackwards("/tmp/file", encoding="utf-8")

# getting lines by lines starting from the last line up
for l in f:
    print l

# do it again
for l in f:
    print l

Another example using python3.3:

#!/usr/bin/env python3.3

from file_read_backwards import FileReadBackwards

f = FileReadBackwards("/tmp/file", encoding="utf-8")

# getting lines by lines starting from the last line up
for l in f:
    print(l)

# do it again
for l in f:
    print(l)

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

1.0.0 (2016-12-18)

  • First release on PyPI.

1.1.0 (2016-12-31)

  • Added support for “latin-1”.

  • Marked the package “Production/Stable”.

1.1.1 (2017-01-09)

  • Updated README.rst for more clarity around encoding support and Python 2.7 and 3 support.

1.1.2 (2017-01-11)

  • Documentation re-arrangement. Usage examples are now in README.rst

  • Minor refactoring

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

file_read_backwards-1.1.2.tar.gz (18.6 kB view hashes)

Uploaded Source

Built Distribution

file_read_backwards-1.1.2-py2.py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page