I want to open a series of sub-folders in a folder and find some text files and print some lines of the text files. I am using this:
from glob import glob
import fileinput
with open('output.txt', 'w') as out:
for line in fileinput.input(glob('*.')):
if 'Subject:' in line:
out.write(line)
This working perfectly only with in one folder but this cannot access the sub-folders as well.so i heard about the os.walk() module. Does anyone know how I can use the os.walk() module to to access sub-folders and extract and paste a particular line in a separate txt file ?