I have 5 directories and 25 text files in each directory. When I try to read text files I got an error msg like '[Errno 2] No such file or directory: 'AEITMYIRQLP.txt'
My codes:
import re
import os
for roots,dirs,files in os.walk(spath):
for file in files:
with open(file,'r') as f:
readf=f.readlines()
for line in readf:
lstNumbers=[]
pattern =re.compile(r'\d{3}-\d{3}-\d{4}')
matches=re.findall(pattern,line)
for match in matches:
lstNumbers.extend(match)