Ok, so the code below uses the re module to find a word 'located'. After it finds the word, it counts up to 10 words after it and extracts all of the words as one string. The only problem I am encountering is that I can't get the script to recognize a new line break, go to the next line, and then continue counting up to 10. If anyone can help, I would greatly appreciate it b/c its stumping me.
Again, any help is appreciated.
Code:
import re
_inputFileName = raw_input("Input File Name: ")
_outputFileName = raw_input("Output File Name: ")
_startingLine = '(located)'
_fin = open(_inputFileName, 'r')
_data = _fin.read()
_counter = 0
for _document in _data.split(_startingLine):
_counter += 1
locpat = 'located((?: \w+){1,10})'
x = re.findall(locpat, _document)
z = len(x)
for line in x:
print line
f = open(_outputFileName, "w")
f.write("Total locations is approximately ")
f.write(`z`)
f.write('\n\n\n')
f.write(str(x).replace(",", "\n"))
f.close()
print 'Total locations is approximately: ', z
raw_input("Press Enter To Close This Window.")
Again, any help is appreciated.