I have an IF function from excel which looks like this:
=WENN('Efficiency Wages'!B2>'Living Wages'!B2;'Efficiency Wages'!B2;"")
("Wenn" means "if" - its german)
So basically if a value of B2 from sheet "Efficiency Wages" is higher than the value of B2 from sheet "Living Wages" then value should be the B2 value from Efficiency Wages. If not than then the cell should be blank. This function is written in another sheet called "new sheet".
My problem: how can i write this IF function in Python? I know that I can start with this:
if ws2.cell(row=2, column= 2).value > ws1.cell(row=2, column= 2).value:
ws3.cell(row=2, column= 2).value = ws2.cell(row=2, column= 2).value
But i dont only want the function for cell B2. It should be a loop because this function goes for 12 columns and 52 rows.
CodePudding user response:
Something like :
for numRow in range(firstRow,firstRow 12 1):
for numCol in range(firstCol,firstCol 12 1):
if ws2.cell(row=numRow, column= numCol).value > ws1.cell(row=numRow, column= numCol).value:
ws3.cell(row=numRow, column= numCol).value = ws2.cell(row=numRow, column= numCol).value
else:
ws3.cell(row=numRow, column= numCol).value = “”