Moving cells with field calculator

611
1
Jump to solution
08-20-2021 05:59 AM
Labels (3)
DarrenDe_Lange
New Contributor III

I am trying to move field entries down by 1 in an attribute table, between a certain row spread. I would like to move all the entries in the 'key biomechanical features' column down by 1 row between row x and row y ('Down' meaning the highlighted key biomechanical field entry in the image moving down to the field below it). I would like all the other columns to stay in their same place, and I would like the other entries in the 'key biomechanical features' column that are not in the row spread to stay in their respective location. enter image description here

exampleexampleIs there a way to do this using the field calculator and python?

Thank you in advance

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Modify this and run it in the python window. Test on a copy!

prev_value = None
with arcpy.da.UpdateCursor("TableName", ["KeyBioMechanicalFeatures"]) as cursor:
    for row in cursor:
        this_value = row[0]
        cursor.updateRow([prev_value])
        prev_value = this_value

 


Have a great day!
Johannes

View solution in original post

1 Reply
JohannesLindner
MVP Frequent Contributor

Modify this and run it in the python window. Test on a copy!

prev_value = None
with arcpy.da.UpdateCursor("TableName", ["KeyBioMechanicalFeatures"]) as cursor:
    for row in cursor:
        this_value = row[0]
        cursor.updateRow([prev_value])
        prev_value = this_value

 


Have a great day!
Johannes