Python tail is a simple implementation of GNU tail and head.
Project description
Python tail is a simple implementation of GNU tail and head.
It provides 3 main functions that can be performed on any file-like object that supports seek() and tell().
tail - read lines from the end of a file
head - read lines from the top of a file
follow - read lines as a file grows
It also comes with pytail, a command line version offering the same functionality as GNU tail. This can be particularly useful on Windows systems that have no tail equivalent.
import tailer
f = open('test.txt', 'w')
for i in range(11):
f.write('Line %d\n' % (i + 1))
f.close()
Tail
# Get the last 3 lines of the file
tailer.tail(open('test.txt'), 3)
# ['Line 9', 'Line 10', 'Line 11']
Head
# Get the first 3 lines of the file
tailer.head(open('test.txt'), 3)
# ['Line 1', 'Line 2', 'Line 3']
Follow
# Follow the file as it grows
for line in tailer.follow(open('test.txt')):
print line
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
tailer-0.2.1.tar.gz
(3.7 kB
view details)
File details
Details for the file tailer-0.2.1.tar.gz.
File metadata
- Download URL: tailer-0.2.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03ea447ba0fa4882554bc42171437ef146da43d5da787b099659113c16b047f3
|
|
| MD5 |
7c9c837227575ba5a0208af7840358a1
|
|
| BLAKE2b-256 |
7804412206c4a2a1816f1e3beb8a952eadec8dca28933a8c1a84e95c37b2a050
|