Find duplicate field values in ArcGIS using VB & Python
script code
1) Create
new field “Short Integer” type to your attribute table (Example= “Duplicate”
2) Open
the field calculator for the newly created field
3) Select
VB script Parser for VB code and Python Parser for Python code.
4) Check
“show codeblock” option, while checking “show codeblock” box a new text box
open at below i.e. to assign output variables.
5) Paste
the following code into the “Pre-Logic VBA Script Code” text box
VB
Script
Static a As Object
Static i As Long
Dim pDuplicate As Integer
Dim pField
pField = [Test] ***(you can choose your field)
If (i = 0) Then
Set a = CreateObject ("Scripting.Dictionary")
End If
If (a.Exists(CStr(sField))) Then
pDuplicate = 1
Else
a.Add CStr(sField), 1
pDuplicate = 0
End If
i = i + 1
Static i As Long
Dim pDuplicate As Integer
Dim pField
pField = [Test] ***(you can choose your field)
If (i = 0) Then
Set a = CreateObject ("Scripting.Dictionary")
End If
If (a.Exists(CStr(sField))) Then
pDuplicate = 1
Else
a.Add CStr(sField), 1
pDuplicate = 0
End If
i = i + 1
And
in the box at the bottom, insert….
pDuplicate
Python
Script
uniqueList = []
def isDuplicate(inValue):
if inValue in uniqueList:
return 1
else:
uniqueList.append(inValue)
return 0
def isDuplicate(inValue):
if inValue in uniqueList:
return 1
else:
uniqueList.append(inValue)
return 0
And in the box at the bottom, insert
How does it works to find duplicated strings?
ReplyDelete