I try to read all the files in a directory, but as they contain spaces and accents, I get errors (already read many posts on SO but cannot find any answer)
this returns a list of files
files = [y for x in os.walk(".") for y in glob(os.path.join(x[0], '*.pdf'))]
but as I try to open them one by one
for file in files:
with open(file,"r") as f:
I get these kind of errors (I obfuscated the letters cos it's confidential):
IOError: [Errno 22] invalid mode ('r') or filename: '.\abcd?efgh (hijk? lmnop).pdf'
I believe the issues are caused by the accents but since it's python that gives me the the file names, I dont understand why they are not compatible with "open()"
regards
how can I fix this ?