Hi,
I have the following problem: I would like to read from a file between to keywords (KEY1 and a line consisting of ------), skipping 4 lines after the first keyword. What I have is the following:
import re
import string
infileName = raw_input("filename ")
infile = open(infileName, 'r')
data = infile.readlines()
counter = True
for index, line in enumerate(data):
if re.search("KEY1:", line):
index += 4
f = 0
while counter:
f = f + 1
print string.split(data[f+index])
if re.search(str([--]), string.split(line)):
counter = False
Has anyone suggestions how I can fix this code? Apparently the re.search doesn't work in the while look and how can I just check for two '--' and break the loop instead searching for the whole line
Thanks,
awa