Memory efficient way of reading files line-by-line from the end of file
Project description
file_read_backwards
Memory efficient way of reading files line-by-line from the end of file
Free software: MIT license
Documentation: https://file-read-backwards.readthedocs.io.
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
Another example using python3.11:
from file_read_backwards import FileReadBackwards with FileReadBackwards("/tmp/file", encoding="utf-8") as frb: # getting lines by lines starting from the last line up for l in frb: print(l)
Another way to consume the file is via readline(), in python3.11:
from file_read_backwards import FileReadBackwards with FileReadBackwards("/tmp/file", encoding="utf-8") as frb: while True: l = frb.readline() if not l: break print(l, end="")
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
1.2.0 (2017-09-01)
Include context manager style as it provides cleaner/automatic close functionality
1.2.1 (2017-09-02)
Made doc strings consistent to Google style and some code linting
1.2.2 (2017-11-19)
Re-release of 1.2.1 for ease of updating pypi page for updated travis & pyup.
2.0.0 (2018-03-23)
Mimicing Python file object behavior.
FileReadBackwards no longer creates multiple iterators (a change of behavior from 1.x.y version)
Adding readline() function retuns one line at a time with a trailing new line and empty string when it reaches end of file. The fine print: the trailing new line will be os.linesep (rather than whichever new line type in the file).
3.0.0 (2023-03-29)
Officially support Python 3.7 - 3.11.
3.1.0 (2024-05-02)
Officially support Python 3.7 - 3.12
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for file_read_backwards-3.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd04593bc1938a003224be451d5d735f1f4490e1e70a568ce8d330bb7652a684 |
|
MD5 | 2614aa9f67486aa0a7b75c8c23cd932b |
|
BLAKE2b-256 | bfe95a3235d4da8be53288fc5bb510d8bab5909fa810beeb4f5c40c3304c8345 |
Hashes for file_read_backwards-3.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dbb65559ca441ea2f5c94121e15e30040fbe9f8b23dff23f979553523c9c303 |
|
MD5 | 1c5b393d805878e8764960c1fa20f5a2 |
|
BLAKE2b-256 | c74fbe7aa2c013c2dc3fd1ab5916eaf2bf11c63ea88811c44c2477c7a9bd9718 |