Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dataframe to template
#1
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.

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']
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Mail Merge from DataFrame into Word Label Template PEGylated_User 0 1,967 Nov-10-2020, 01:01 PM
Last Post: PEGylated_User

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020