Jul-01-2020, 04:24 PM
Hello,
How would I go about copying a dataframe to an excel template without overwriting data in the template? The template has 10 tabs with data in it. I want to copy the dataframe and paste it into template tab 'data1' column B, row 15.
How would I go about copying a dataframe to an excel template without overwriting data in the template? The template has 10 tabs with data in it. I want to copy the dataframe and paste it into template tab 'data1' column B, row 15.
import pandas as pd import openpyxl as xl df1 = pd.read_excel('C:\\work\\All_Data.xlsx', sheet_name = 'Report1', nrows=9, header=None) df2 = pd.read_excel('C:\\work\\All_Data.xlsx', sheet_name = 'Report1', skiprows=9, header=None) df2 = df2[df2["Direction"].str.contains("Down*", na=False)] df2 = df2[(df2['Time Step'] >= '0.09:00:00') & (df2['Time Step'] <= '0.09:01:39')] template = xl.load_workbook('C:\\work\\Template.xlsx') template_sheet_name = template['data1']