Extract text around a list of words in python 3.x -


i extract few lines (perhaps 100 or characters) of text text files. have list of words extract around. have following code want except lines not long enough capture need.

import os  ngwrds=[long list of words]  filename in os.listdir(os.getcwd()):         open(filename, 'r') searchfile:             line in searchfile:                 if any(x in line x in ngwrds):                     open("extract.txt", 'a') out:                         out.write("{} {} \n".format(filename, line)) 

any thoughts? thank you.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -