UpdateCursor not updating attributes

3196
1
Jump to solution
10-13-2014 07:56 AM
Hernando_CountyProperty_Apprai
New Contributor III

I'm using ArcCafe's shiftfeature example and it is working great for shifting the shape.  However I want to add an update to one of the attributes and that is not working.  Here is my code.  The script runs fine and acts like it's working but when I go into the attribute table after running it non of my keynumbers show up...all are still null.  What am I doing wrong?

def shift_features(in_features,  keynumber, x_shift=None, y_shift=None):

    ikeynumber = int(keynumber)

    with arcpy.da.UpdateCursor(in_features, ['SHAPE@XY','KEYNUMBER']) as cursor:

        for row in cursor:

             cursor.updateRow([[row[0][0] + (x_shift or 0),

                               row[0][1] + (y_shift or 0)], ikeynumber])

    return

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi Priscilla,

Your script looks correct.  What type of field is KEYNUMBER?

Try removing the XY update and see if you are able to just update this field.  Ex:

def shift_features(in_features, keynumber):

    ikeynumber = int(keynumber)

    with arcpy.da.UpdateCursor(in_features, ['KEYNUMBER']) as cursor:

        for row in cursor:

            cursor.updateRow([ikeynumber])

    return

View solution in original post

0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor

Hi Priscilla,

Your script looks correct.  What type of field is KEYNUMBER?

Try removing the XY update and see if you are able to just update this field.  Ex:

def shift_features(in_features, keynumber):

    ikeynumber = int(keynumber)

    with arcpy.da.UpdateCursor(in_features, ['KEYNUMBER']) as cursor:

        for row in cursor:

            cursor.updateRow([ikeynumber])

    return

0 Kudos