Closed kurtabersold closed 9 years ago
You're probably better off putting in some kind of error-checking instead. What's the exact error you're getting?
The error actually drives from csv.reader, but the null byte is present in line when iterating through the log. I believe this only happens when reading the last line of the log, and that line is not yet fully written.
for line in P:
nullByte = line.find('\x00')
if nullByte != -1:
print 'Null Byte Found'
csvReader = csv.reader([line])
Results in the following error:
Null Byte Found
_csv.Error: line contains NULL byte
Is this on RHEL by any chance? https://access.redhat.com/solutions/22717
No, I am running Ubuntu 12.04.2 LTS.
PR 27 fixes issue. It may be desirable to not read only whole lines, but since I am parsing log lines, reading an incomplete line breaks functionality.
I am occasionally getting a line contains NULL byte error while reading the contents of line. It appears that the line is not fully written. If it makes a difference, the file is on an NFS mount. Is there a way for pygtail to read all but the last line of the file?