python Error 999999 in duplicate append script.

1006
12
Jump to solution
06-27-2023 10:15 AM
Laura_m_Conner
New Contributor III

All,
Recently we have finished innovatory of curbed streets. The curbed streets were appended into a new feature class in batches as an area was finished. Now I am checking to make sure no street segment got appended twice. I have written/modified it the script from Delete the older records of duplicate features after using the Append tool in ArcGIS Pro, for our data.

I am encountering Error 999999. None of the advice from 999999: Something unexpected caused the tool to fail seems applicable. There is no output file, only the original input file is being modified. There is no geometry network. The used fields do not have any null values. Given where it fails in the script, size should not be an issue. Also, there are only about 9,600 records in the table currently. For testing the script, I am running this on a copy of the data set exported from the enterprise geodatabase to the project database. once the script works, it will be run on the enterprise geodatabase copy. I am unable to test it in administrator mode, but I don't see a reason why this should be an issue.

How do I get the script working, or at least get past this error? Any insight is appreciated.
Script:

 

import arcpy

fc = "StormCurbedStr_ExportFeature"
feilds = ["FULLNAME","curb","Shape"]

cursor = arcpy.UpdateCursor(fc, feilds)

keepList = list()
for row in cursor:
    row_val_0 = row.getValue(feilds[0])
    row_val_1 = row.getValue(feilds[1])
    row_val_2 = row.getValue(feilds[2])
    row_val = row_val_0 + row_val_1 + str(row_val_2)
    
    if row_val not in keepList:
        keepList.append(row_val)

    elif row_val in keepList:
        cursor.deleteRow(row)
    
    else:
        pass
print("done")

 

 

error:

 

RuntimeError                              Traceback (most recent call last)
In  [5]:
Line 7:     cursor = arcpy.UpdateCursor(fc, feilds)

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py, in UpdateCursor:
Line 1234:  return gp.updateCursor(dataset, where_clause, spatial_reference, fields, sort_fields)

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in updateCursor:
Line 374:   self._gp.UpdateCursor(*gp_fixargs(args, True)))

RuntimeError: 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

 

 

notes:

Arcpro 3.1.0

OS: Mircrosoft windows 10 pro for workstations

 

Thank You.

Laura

 

 

 

 

  

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AlfredBaldenweck
MVP Regular Contributor

If you switched to arcpy.da.UpdateCursor(), it changed the object that it's delivering to you from a row type to a tuple. Each row is (Fullname, curb, Shape)

Just call: row_value_0 = row[0] , etc.

Actually, you could probably shorten it to:

import arcpy

fc = r"N:\laura\edit_map4\edit_map4.gdb\StormCurbedStr_ExportFeature"
feilds = ["FULLNAME","curb","Shape"]
keepList = list()

with arcpy.UpdateCursor(fc, feilds) as cursor:
    for row in cursor:
        row_val = row[0] + row[1] + str(row[2])
    
        if row_val not in keepList:
            keepList.append(row_val)

        elif row_val in keepList:
            cursor.deleteRow(row)
    
        else:
            pass
print("done")

 

Alternatively, you could try appending the entire row to keep list, rather than doing any sort of processing on it.

import arcpy

fc = r"N:\laura\edit_map4\edit_map4.gdb\StormCurbedStr_ExportFeature"
feilds = ["FULLNAME","curb","Shape"]
keepList = list()

with arcpy.UpdateCursor(fc, feilds) as cursor:
    for row in cursor:    
        if row not in keepList:
            keepList.append(row)

        elif row in keepList:
            cursor.deleteRow(row)
    
        else:
            pass
print("done")

View solution in original post

0 Kudos
12 Replies
AlfredBaldenweck
MVP Regular Contributor

Typically cursors are done with a "with"

Not sure if this would actually change anything, but maybe give it a shot?

import arcpy

fc = "StormCurbedStr_ExportFeature"
feilds = ["FULLNAME","curb","Shape"]

keepList = list()
with arcpy.UpdateCursor(fc, feilds) as cursor:
    for row in cursor:
        row_val_0 = row.getValue(feilds[0])
        row_val_1 = row.getValue(feilds[1])
        row_val_2 = row.getValue(feilds[2])
        row_val = row_val_0 + row_val_1 + str(row_val_2)
        
        if row_val not in keepList:
            keepList.append(row_val)

        elif row_val in keepList:
            cursor.deleteRow(row)
        
        else:
            pass
    print("done")

 

0 Kudos
Laura_m_Conner
New Contributor III

thanks for the reply 

I have tried it and got the same error.

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Well, it was worth a shot.

The other thing that isn't clear from your code sample is if you're actually inputting the feature class or just its name.

Like, is your fc variable  r"Documents\Projects\Example.gdb\StormCurbedStr_ExportFeature", or is it  r"StormCurbedStr_ExportFeature" and you just censored it to share?

 

0 Kudos
Laura_m_Conner
New Contributor III

to clarify I am running the script inside the arc pro in a notebook. what i put in the post is verbatim what I have.

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Okay yeah, you need to actually give it the full name of whatever feature class you have.

Currently you're giving it just the name of the feature class without the full path, which is like telling someone to find "John". John who?

0 Kudos
Laura_m_Conner
New Contributor III

well it fisxed that error but gave me another one. right now the  script is 

import arcpy

fc = r"N:\laura\edit_map4\edit_map4.gdb\StormCurbedStr_ExportFeature"
feilds = ["FULLNAME","curb","Shape"]
keepList = list()

with arcpy.UpdateCursor(fc, feilds) as cursor:

    for row in cursor:
        row_val_0 = row.getValue(feilds[0])
        row_val_1 = row.getValue(feilds[1])
        row_val_2 = row.getValue(feilds[2])
        row_val = row_val_0 + row_val_1 + str(row_val_2)
    
        if row_val not in keepList:
            keepList.append(row_val)

        elif row_val in keepList:
            cursor.deleteRow(row)
    
        else:
            pass
print("done")

  the current error:

AttributeError                            Traceback (most recent call last)
In  [10]:
Line 7:     with arcpy.UpdateCursor(fc, feilds) as cursor:

AttributeError: __enter__
0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Not sure if this will fix this error, but:

You are using the old UpdateCursor, whose parameters must be put in the following order:

UpdateCursor (dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields})

Try arcpy.UpdateCursor(fc, fields= feilds) to call the fields parameter out of order.

Alternatively, if you want to keep it as you've already written, change to the new arcpy.da.UpdateCursor() , which uses the parameter order you're currently using

arcpy.da.UpdateCursor (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause}, {datum_transformation}, {explicit})

 

0 Kudos
Laura_m_Conner
New Contributor III

ok i have updated the updatecursor function to and ran the  script. the next error is...

AttributeError                            Traceback (most recent call last)
In  [13]:
Line 10:    row_val_0 = row.getValue(feilds[0])

AttributeError: 'list' object has no attribute 'getValue'
 

 

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

If you switched to arcpy.da.UpdateCursor(), it changed the object that it's delivering to you from a row type to a tuple. Each row is (Fullname, curb, Shape)

Just call: row_value_0 = row[0] , etc.

Actually, you could probably shorten it to:

import arcpy

fc = r"N:\laura\edit_map4\edit_map4.gdb\StormCurbedStr_ExportFeature"
feilds = ["FULLNAME","curb","Shape"]
keepList = list()

with arcpy.UpdateCursor(fc, feilds) as cursor:
    for row in cursor:
        row_val = row[0] + row[1] + str(row[2])
    
        if row_val not in keepList:
            keepList.append(row_val)

        elif row_val in keepList:
            cursor.deleteRow(row)
    
        else:
            pass
print("done")

 

Alternatively, you could try appending the entire row to keep list, rather than doing any sort of processing on it.

import arcpy

fc = r"N:\laura\edit_map4\edit_map4.gdb\StormCurbedStr_ExportFeature"
feilds = ["FULLNAME","curb","Shape"]
keepList = list()

with arcpy.UpdateCursor(fc, feilds) as cursor:
    for row in cursor:    
        if row not in keepList:
            keepList.append(row)

        elif row in keepList:
            cursor.deleteRow(row)
    
        else:
            pass
print("done")
0 Kudos