So if i use
tail 'path'
to view last few lines of text file I get 9 lines of data in this format:
20-3-2015 16:7:13 6
I use
splitted = file_open(name).rstrip().split(" ");
where the file_open function is
def file_open(name):
f_name = prefix + name;
offs = -10;
with open(f_name, 'r') as f: # Open file to read
while True:
f.seek(offs,2) # Jump to final line and go to point in line to begin
lines = f.readlines();
if len(lines) >= 2:
return lines[-1]
offs *= 2;
This should open file, go to last line return the full last line and then split up the three columns.
Instead the value of splitted is
['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']
whereas it should obviously be the final line. I have been using this code perfectly fine but all of a sudden I am getting this issue.