How to write to an existing excel file using python

Viewed 34

I have an existing excel sheet that has a large number of rows and columns, I want to add some missing values to some specific rows, is it possible to write to an existing excel file without corrupting the file? Please help me.

enter image description here

When I was trying to append the data using the following code, the data was added to the bottom as mentioned in the below screenshot.

Shift = 'GS | GS'
data_list = {'01 Sep 2022': [Shift]}
df = pd.DataFrame(data_list)
current_data = pd.read_excel (file_name)
append = pd.concat([current_data,df])
writer = pd.ExcelWriter(file_name, engine='xlsxwriter')
write = append.to_excel(writer, index=False)
writer.save()

enter image description here

0 Answers
Related