Hi,
I want to make a python program which allows to read data from a file starting from a line with a certain keyword, skipping 4 lines, beginning to write the contents to an output file and stopping after n lines.
I tried so far an input with the re.search() command but I couldn't find a solution for skipping lines and stopping after a certain amount of lines. What I have so far is:
import re
infileName1 = raw_input("Enter filename ")
infile1 = open(infileName1, 'r')
data1 = infile1.readlines()
outfile = open("test.txt", 'w')
for line in data1:
parameters = line
if re.search("KEYWORD",line):
count = 1
for i in range(count):
outfile_temp.write(parameters)
So it starts printing from the keyword but doesn't stop.
If anyone has suggestions or ideas, thanks a lot.
awa