I am trying to iterate through a folder containing about 5 files (this will continue to increase each month). Presently the files which are xlsx files are password protected. I need to read the contents of these files into my pandas dataframe. Currently, when I try the following code I get the error message: XLRDError: Can't find workbook in OLE2 compound document
I am trying to find an approach which does not require manual intervention with the password potentially baked in. I saw some examples of code online referring to the win32 library but couldn't find one that involved both win32 and pandas.
from glob import glob
import os
monthly_cvr_root = glob("C:/path_to_files/*.xlsx")
df3 = pd.DataFrame()
for files in monthly_cvr_root:
data = pd.read_excel(files, header=None)
data['EffectiveDate'] = os.path.basename(files)[11:19]
df3 = df3.append(data)
df3
Any help is appreciated. Thanks!