Python Pandas: Copy CSV to Excel without overwriting

Viewed 33

There is one CSV file with many rows and columns of data that needs to be copied into sheet1 starting at row 11 of a "master" Excel .xlsx file.

There are graphs and formatting in the "master" excel file that need to be preserved. The problem that I'm having is that the "master" Excel file, python_out.xlsx, is overwritten with my code and the graphs and formatting are wiped out.

I've found a couple of helps like Write values to a particular cell in a sheet in pandas in python but they are only writing a few cells worth of data and not copying over an entire .csv file.

import os
import pandas as pd
from openpyxl import load_workbook
    
    
read_file = pd.read_csv(r'C:\4336Gen5 size\Noise\mode0\mode_0_40c_noise.csv')
    
read_file.to_excel(r'C:\4336Gen5 size\Noise\mode0\python_out.xlsx', startcol=0, startrow = 10, index = None, header = True)
0 Answers
Related