我有一个名为 as的模板excel 文件,template.xlsx
其中包含许多工作表。我想将数据从一个单独的.csv
文件复制到template.xlsx
(命名为data
)的第一张纸中,并将新文件另存为,result.xlsx
同时保留原始模板文件。
我想粘贴从第二排开始的数据data
的表template.xlsx
这是我迄今为止开发的代码
import pandas as pd
from openpyxl.utils.dataframe import dataframe_to_rows
import openpyxl
from shutil import copyfile
template_file = 'template.xlsx' # Has a header in row 1 already which needs to be skipped while pasting data but it should be there in the output file
output_file = 'result.xlsx'
copyfile(template_file, output_file)
df = pd.read_csv('input_file.csv') #The file which is to be pasted in the template …
Run Code Online (Sandbox Code Playgroud)