Select to view content in your preferred language

How to indentify duplicate or unique value in Pro RuntimeError: Error 999999

3196
11
Jump to solution
02-23-2021 09:07 AM
JaredPilbeam2
MVP Alum

I'm using the How to identify duplicate or unique values in Pro code provided by ERSI  verbatim, and I'm getting an error. I have a feature class table that I'm looking for duplicates in. The technical document doesn't say whether to use the field name or alias, so I tried both. When I run it with the field name the code throws an exception. I stopped the script and opened Pro. The field gets created in the table but it's all NULLs.

This is the line where the exception is being thrown:

 

 

 

i=row.getValue(field_in)

 

 

 

Exception/Error:

 

 

 

  Message=ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
  Source=\\GISFILE\GISSTAFF\Jared\Python Scripts\ArcGISPro\DuplicateFields.py
  StackTrace:
  File "\\GISFILE\GISSTAFF\Jared\Python Scripts\ArcGISPro\DuplicateFields.py", line 17, in <module>
    i=row.getValue(field_in)

 

 

 

 

When I run it with the alias it doesn't finish, or at least I've never let it because it's taking a remarkably long time. However, if I stop the script and open Pro to view the table, a lot of the 190K+ fields are written to. But, like I said it never finishes...

Code:

 

 

 

import arcpy

'''
This script will count the number of occurences of a value in a field ("field_in") and write them to a 
new field ("field_out")
'''

arcpy.env.workspace = r"C:\Users\jpilbeam\Downloads\DuplicateTesting.gdb\DuplicateTesting.gdb" #path to GDB goes here
infeature = "backup_02232021" #name of feature class goes here
field_in = "name" #this is the alias of the field. Name: is the actual name
field_out = "COUNT_"+field_in
arcpy.AddField_management(infeature, field_out,"SHORT")

lista= []
cursor1=arcpy.SearchCursor(infeature)
for row in cursor1:
    i=row.getValue(field_in) #<-- where exception is thrown using field name in field_in variable
    lista.append(i)
del cursor1, row

cursor2=arcpy.UpdateCursor(infeature)
for row in cursor2:
    i=row.getValue(field_in)
    occ=lista.count(i)
    row.setValue(field_out, occ)
    cursor2.updateRow(row)
del cursor2, row
print("----done----")

 

 

 

EDIT: Using the alias, I let the code run for like 15-20 mins and it finished with no errors! So, I guess it just needs that long with all these records?

 

0 Kudos
11 Replies
DanPatterson
MVP Esteemed Contributor

perhaps there are leading or trailing spaces in the field names if it was produced in Survey123.  That would be a fieldname killer for sure.


... sort of retired...
0 Kudos
JaredPilbeam2
MVP Alum

Thanks for the reply about using numpy. I'm not that advanced yet, but i'll earmark the post.

0 Kudos