I have an excel workbook with 40 wooksheets with names as years (1982-2022). I need to save these individual worksheets and rename eg. as imdbt1982,

  Kiến thức lập trình

I need to rename the sheets as imdbt1982, imdbt1983 ,,,…imdbt2022 and save them as individual workbooks

sheets = ['1982', '1983', '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022']

for i, sheet in enumerate(sheets):
    globals()['df' + str(i + 1)] = pd.read_excel(path_track, sheet_name = sheet)
sheets

New contributor

user12578470 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

LEAVE A COMMENT