I have some code to write a pandas dataframe to an excel sheet and for some reason it just doesn't do anything. I have used the same method previously with success.

book = load_workbook(os.path.commonpath(output)) #user is prompted for output file earlier in program
writer = pd.ExcelWriter(os.path.commonpath(output), engine = 'openpyxl')
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)

df.to_excel(writer, sheet_name = 'Check', startrow = writer.sheets['Check'].max_row, index = False) # this should write the df out starting at the first row that doesn't contain any data in the excel sheet. 

The program runs fine, just no output to the excel sheet when I open it. Any ideas?

1 Answers

1
dTanMan On Best Solutions

I believe you need a writer.save() at the end of your code!