A Simple line generator from tail of file
Project description
readtail
Simple Description
- A simplest generator function written in pure python
- Seek from the tail of the file
Install
pip install tailread
Useage
from tailread import readlines
# The file must be opened in bytes mode.
for line in readlines(open('access.log', 'rb')):
print(line)
# Can stop reading
if 'some string' in line:
break
# or from file path
for line in readlines('access.log'):
print(line)
# b'line 10\r\n'
# b'line 9\r\n'
# b'line 8\r\n'
# b'line 7\r\n'
# ....
# decoding lines from encoding info
for line in readlines('access.log', encoding='utf-8', errors='ignore'):
print(line)
# line 10
# line 9
# line 8
# line 7
# ....
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
tailread-1.0.0.tar.gz
(2.0 kB
view details)
File details
Details for the file tailread-1.0.0.tar.gz
.
File metadata
- Download URL: tailread-1.0.0.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e730eb563b00d02cbafa10098eee51074fb7b3614d56be866298b7d52dfea6ca |
|
MD5 | 8f37c1ecdffd85f3c3c4f2934e93bfb4 |
|
BLAKE2b-256 | 58c6046e0dfea6d64c407a111c8830e922797a3ef04a91b603c7c0bacab64e27 |