Hello everyone,
I would like to loop thru a given directory and seach in all pre-filtered files for a search word. I prepared this code, but it is not looping thru all files, only the last file which was found is analyzed. Ideally all files should be analyzed and the output should be saved in a textfile. Could someone help? Thank you in advance!
import os, glob
for filename in glob.glob("C:\\test*.xml"):
print filename
for line in open(filename):
if "SEARCHWORD" in line:
print line
The OUTPUT is looking like:
C:\test-261.xml
C:\test-262.xml
C:\test-263.xml
C:\test-264.xml
<Area>SEARCHWORD</Area>
Thank you!