i am trying to copy first 18 rows from test2 file to test1 file in sheet2,, it copies data but also turns test1 file into single sheet named "sheet2" and sheet1 of test1 file gets deleted
i have tried xlsxwriter but it adds other sheets in the file. I do not want to write data into new sheets. I want to copy data into another sheet without deleting other sheets of that excel file.
This is code i am trying, so test2 has the data, i want to copy first 18 rows, then paste it in sheet2 of test1 file having 2 sheets, the code does copy the data but sheet1 of test1 file gets deleted. i want to keep the other sheets and copy the data in sheet2.
df=pd.read_excel(r'F:\test2.xlsx')
slc=df.iloc[1:1+18,:]
slc_transposed = slc.T
print(slc_transposed)
slc_transposed.to_excel(r'F:\test1.xlsx','Sheet2',startrow=5,startcol=2)
to_excel
doesn't modify an exiting file, it creates a new one - Yucaopenpyxl
- Yuca