-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReturnDuplicateAddresses.py
39 lines (27 loc) · 1.01 KB
/
ReturnDuplicateAddresses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import arcpy
#fldList should be the field with duplicates to find and the Shape field
def returnDuplicateAddresses(inPts, fldList):
if 'OBJECTID' not in fldList:
fldList.append('OBJECTID')
seenDict = {}
dupList = []
duplicates = {}
with arcpy.da.SearchCursor(inPts, fldList) as sCursor:
for row in sCursor:
if row[0] not in seenDict:
seenDict.setdefault(row[0])
else:
dupList.append(row[0])
sCursor.reset()
for row in sCursor:
if row[0] in dupList:
dupes = duplicates.setdefault(row[-1], [])
dupes.extend([row[0], row[1]])
return duplicates
def updateErrorPts(updatePts, errorPtsFlds, duplicateDictionary):
iCursor = arcpy.da.InsertCursor(updatePts, errorPtsFlds)
for d in duplicateDictionary:
add = duplicateDictionary[d][0]
note = 'duplicate address'
shp = duplicateDictionary[d][1]
iCursor.insertRow((add, note, shp))