简体   繁体   中英

pandas - reading dynamically named file within a .zip

I am creating a new dataframe in pandas as below:

df = pd.read_excel(zipfile.open('zipfilename 2017-06-28.xlsx'), header=1, names=cols )

The single .xlsx within the .zip is dynamically named (so changes based on the date).

This means I need to change the name of the .xlsx in my code each time I open the .zip to account for the dynamically named .xlsx.

Is there a way to make pandas read the file within the .zip, regardless of the name of the file? Or to return the name of the .xlsx within the line of code somehow?

Thanks

使用读取文件

df = pd.read_excel('zipfilename 2017-06-28.xlsx',compression='zip', header=1, names=cols)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM