Skip to content
Advertisement

Append dataframes to multiple Excel sheets

I’m trying to append 3 dataframes to 3 existing sheets in an Excel file (one dataframe per sheet).

This is my code:

JavaScript

However, the new data overwrites the old data rather than being appended at the end of the corresponding sheet. Note that I set mode="a" and if_sheet_exists="overlay", yet it overwrites and doesn’t append.

How should I fix it?

Advertisement

Answer

You have to find last row and land new dataframe after it. assuming you have some data in place and all headers, you can test like below:

JavaScript

function .shape gives the amount of rows and columns for example (1235,66), – using .shape[0], only amount of rows is taken

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement