fileinput.input, readlines and ...
Przemyslaw Bak
mail131 at gmail.com
Wed Jun 24 06:23:30 EDT 2009
Hello,
I many files with log data. The structure of the file is quite
inconvenience and similar to the following example:
Data1
ValueA
Data2
ValueB
Data3
ValueC
...
To get the values I need to find Data* and then get to the next line.
I tried to use fileinput.input :
...
for line in fileinput.input(filename):
if line.find("Data2") >= 0:
(now what ?)
So I can find the requested line (Data2) but how to get value from the
next line ?
Is the fileinput.input the most convenient for this type of task ?
Maybe
readline or readlines would be better ?
What can you recommend ?
Regards
More information about the Python-list
mailing list