Skip to main content

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


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

Uploaded Source

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