I have a vector layer in which I have added some fields of type 'float' using arcpy.AddField_management. I'm performing simple calculations between those fields using update cursors but the problem is that when I divide the values by 0, I get a run-time error even though I'm using Inf with the float function.
This is my code:
with arcpy.da.UpdateCursor('flurstcuke_cropped5', ['FID','totresgeb', 'totresgbpt','difresarea','scaledif']) as cursor6:
for row6 in cursor6:
row6[3] = row6[2] - row6[1]
try:
row6[4] = ((row6[2] - row6[1])/row6[1]) * 100
except ZeroDivisionError:
row6[4] = float('INF')
cursor6.updateRow([row6[0], row6[1], row6[2], row6[3], row6[4]])
The message I get is that 'the value type is incompatible with the field type. [scaledif].' And I know it's referring to Inf since I have also set up a counter in my script to determine where the program is. But I don't understand that since 'Inf' is a floating number here and the field's type is also float