I have two "A" fields and "B" and I want to use the field calculator in the "C" field to determine if they are equal
put 1 if they are equal and 0 if they not
example
A | B | C |
3 | 3 | 1 |
5 | 7 | 0 |
I found this scrip
but it only works in python window
import arcpy
fc = R 'c: \ path \ to \ your \ fc'
with arcpy.da.UpdateCursor (fc, ["FIELD1", "FIELD2", "FIELD3"]) as cursor:
for row in cursor:
if row [0] == row [1]:
row [2] = 1
else:
row [2] = 0
cursor.updateRow (row)
"I want to use the field calculator"
or as a tool for modelbuidel where "fc = R'c: \ path \ to \ your \ fc ' can be a Shapefile imput
Hi Gustavo,
Try below:
Script:
def isEqual(x,y):
if x == y:
return 1
else:
return 0
Or in VBScript:
thank you very much for your answer
Of course both meant to point out that you would replace their field names with yours...in the case of python you need to remember that field names are enclosed in ! marks whereas in VBscript they are surrounded by square brackets. Also, in python, the equality check is == whereas in VBscript a single = will suffice.