Deeksha
Deeksha

Reputation: 1

How to update a cell value in excel in Python

I have a spreadsheet which is having following columns: TestID TestData ExpectedOutput ActualOutput Result

I have separate python scripts for each test-id. I need to read the row corresponding to that particular test-id and after execution, need to update result in same spreadsheet. I am not able to update that result value. can someone please help? I read the spreadsheet using Pandas. e.g. a row in spread sheet:

TestID TestData ExpectedOutput ActualOutput Result

Testid-1 Min_freq=5,Max_freq=60, Drive started Drive started Pass

My script would search for this testid and read the test data. after execution, it would compare the output with expected output and accordingly would update the value of cell Result. I am not getting how to update result value.

Please help me.

Upvotes: 0

Views: 1333

Answers (1)

George Y
George Y

Reputation: 535

The only package that can modify/edit an existing excel is openpyxl You can read it by xlrd, but cannot modify it by xlwt or xlsxwriter, which can create and flash new xls and xlsx.

However, if you are using another source to edit the existing excel, they are not editing the same ones but two template mirror files, be sure to save it before letting python to read it, and vise versa.

Upvotes: 2

Related Questions