Nov-18-2019, 11:31 AM
Most likely you have a empty cell in
Check cell after value 7.155.
To make the error.
transactions.xlsx
.Check cell after value 7.155.
To make the error.
>>> cell = None >>> cell * 0.9 Traceback (most recent call last): File "<interactive input>", line 1, in <module> TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'You can fix file bye add a value,or bypass(
pass
) the error as shown under.import openpyxl as xl wb = xl.load_workbook('transactions.xlsx') sheet = wb['Sheet1'] cell = sheet['a1'] cell = sheet.cell(1, 1) print(cell.value) for row in range(2, sheet.max_row + 1): cell = sheet.cell(row, 3) try: corrected_price = cell.value * 0.9 except TypeError: pass corrected_price_cell = sheet.cell(row, 4) corrected_price_cell.value = corrected_price print(corrected_price) wb.save('transactions 2.xlsx')