First things first, I would recommend opening files this way:
with open(filename) as file:
""" Do some stuff """
This guarantees that no matter what happens with your code (unexpected error, hangs, etc.) the file will always be closed properly.
As for the other tasks - once you've found your line ("performance summary"), you can traverse to the next line manually by calling
next(file) # returns the next line in the file Since 'next(file)' gives the next line from the current position in the file, you could call it after you've found your line, and then start parsing those data/numbers lines.
I wrote a quick and dirty example that puts it all together:
with open(filename) as file:
for line in file:
if 'Performance Summary' in line: # the line we want
data_lines = []
for i in range(3):
next(file) # advance 3 lines
data = next(file).strip() # read the 4'th line, remove redundant spaces
while data: # while data isn't an empty line (empty lines == False in python)
data_lines += data # store in list
data = next(file).strip() # keep reading...
break # stop checking the rest of lines in the file After you have the list 'data_lines', you can parse each item in it and write the results to another file.
Hope this helps a bit - good luck :-)