I have a folder in dropbox with path:
C:\Users\Sophocles PC\Dropbox\RGS Delivery\Impact Coefficients\Consumer Discretionary\CD_LG_Apparel_Accessories_Luxury_Goods\Data\CD_LG_DataOutputs
and I want to import the last modified .xlsx
file. I use the code:
list_of_files = glob.glob(r'C:\Users\Sophocles PC\Dropbox\RGS Delivery\Impact Coefficients\Consumer Discretionary\CD_LG_Apparel_Accessories_Luxury_Goods\Data\CD_LG_DataOutputs/*')
latest_file = max(list_of_files, key=os.path.getctime)
the latest_file
, prints:
C:\Users\Sophocles PC\Dropbox\RGS Delivery\Impact Coefficients\Consumer Discretionary\CD_LG_Apparel_Accessories_Luxury_Goods\Data\CD_LG_DataOutputs\~$CD_LG_Results - 2020-11-27 - mean - v2.xlsx
which is in fact the latest file, and therefore the file I want to import. However, when I try to import the file:
x = pd.read_excel(latest_file)
I get the following error: XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'\x0cSophocl'
I don't know how to fix the error, but I also think that fixing this should be fairly straight forward. Any help on this will be appreciated. Thank you.