Reputation: 21
I'm working on a Windows 10 machine (win32, Python 3.8.2). I'm using pandas to read in two excel files as dataframes, then using Openpyxl to write data to an existing Excel file (that has data and formulas already in the sheet). The approach I'm using now with Openpyxl works, but is quite time-consuming. I'm wondering if there's another, faster approach to writing data to an existing Excel sheet? I feel like this could possibly be done by appending my dataframe(s) to the existing Excel sheet, but I've read online that the sheet I am writing to would have all of its data erased before my data is written to it. Here are some of the resources I've read about this issue on:
How to write to an existing excel file without overwriting data (using pandas)?
Append existing excel sheet with new dataframe using python pandas
Upvotes: 1
Views: 685
Reputation: 4924
I would pull it in with pd.read_csv(), do manipulations then write with df.to_csv(). Do you need to keep it in the excel format? I tend to find that this is not worth it.
Upvotes: 0