Reputation: 783
Ideally I'm building a self-updating mechanism. The last thing I need to do is save content from "dff" to the next empty row in an existing excel sheet "test.xlsx".
book = load_workbook("test.xlsx")
writer = pd.ExcelWriter('test.xlsx', engine='openpyxl')
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
dff.to_excel(writer, startrow=len(dff), header=None)
writer.save()
The issue is around the 2nd last row, the "startrow=" part. So far I can make it enter the dataframe content to row 3, but it overwrites the contents.
Say I have content 08/09-2019 00, 00, 00, 00 How would I add it to the next empty row of my excel sheet?
Upvotes: 0
Views: 2021
Reputation: 2810
Try this
dff.to_excel(writer, startrow=len(dff)+1, header=False, index=False)
Upvotes: 2