I am trying to copy an excel file and rename it. For example I have a file HI.xlsx and I want to copy it and rename it as BYE.xlsx.
My code to do this is below and when I run it, the file BYE.xlsx is created, but it is corrupted. 
Here is what I am using:
fIn = open(r"HI.xlsx")
fOut = open(r"BYE.xlsx", "w")
                Below you can see code example. Copy def copy_worksheet(self): \# Instantiating a Workbook object by excel file path workbook = self. Workbook(self. dataDir + "Book1.
You should be using shutil.copy():
shutil.copy("HI.xlsx", "BYE.xlsx")
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With