In order to extract some values from this file :
I need to read it line by line.
I tried to read line by line first but i don't know why it doesn't work.
I tried this :
#! /usr/bin/python
file = open('/home/results/err.txt')
for line in file.readline():
print line
EDIT:
Problem: working but not showing this lines (this is the file)
Just the last line of them which is: (this is what is generated)
Answer
You need to iterate through the file rather than the line:
#! /usr/bin/python
file = open('/home/results/err.txt')
for line in file:
print line
file.readline()
only reads the first line. When you iterate over it, you are iterating over the characters in the line.
No comments:
Post a Comment