AnsweredAssumed Answered

ZeroDivisionError:

Question asked by clintoncooper on Jan 13, 2014
Latest reply on Jan 13, 2014 by clintoncooper
I have a large dataset where I need to run a lot of calculations.  it contains roughly 100 fields.  I have created a script that runs an update cursor to calculate some new fields based on a few other fields.  Well I am running into the problem where if there is a zero in the field that is a divisor, I get this error: 

Runtime error  Traceback (most recent call last):   File "<string>", line 36, in <module> ZeroDivisionError: float division by zero


I am looking for how to construct an if statement that will first determine if the calculation will create this error, then if it does, it will make the value 0

my first try of this:
if ((row[32]/row[3])/(row[30]/row[3]) =0):    row[84]= (row[32]/row[3])/(row[30]/row[3]) else:   row[84]= 0


did not work.  Any help on how to make this if statement work would be much appreciated!!!  Thanks in advance!!

Clinton

Outcomes