Python Forum
ARCPY using the arcpy.da.UpdateCursor
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ARCPY using the arcpy.da.UpdateCursor
#1
Howdy,

I am trying to get this script to create Grid Numbers for me in a mapping fishnet,  but I am running into troubl with the error listed below  - any suggestions ?

import arcpy

arcpy.AddField_management("N:\GIS\Projects\Steve_Eastwood_Landuse\Plant_Biosecurity_Project\A0_Maps\Ao_template_Maps.gdb\Data\NTLLS_Fishnet" ,"REF","TEXT","","","5")
rowCount = 0
with arcpy.da.UpdateCursor("N:\GIS\Projects\Steve_Eastwood_Landuse\Plant_Biosecurity_Project\A0_Maps\Ao_template_Maps.gdb\Data\NTLLS_Fishnet",["OID","REF"]) as cursor:
    for row in cursor:
        leftPart = (rowCount % 4) + 1
        rightPart = ["A","B","C"][row[0] % 4]
        row[1] = str(leftPart)+str(rightPart)
        cursor.updateRow(row)


        if ((row[0]) % 64) == 63:
            rowCount = rowCount + 1
Error:
Traceback (most recent call last):   File "C:\Users\hawkinle\Desktop\STDTAS\Fishnet2.py", line 8, in <module>     rightPart = ["A","B","C"][row[0] % 4] IndexError: list index out of range [Finished in 14.8s]
Thanks Leith
Reply


Messages In This Thread
ARCPY using the arcpy.da.UpdateCursor - by CornJulio - Oct-12-2016, 03:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Iterating an attribute table using Arcpy teflon 6 4,051 Oct-28-2019, 09:15 PM
Last Post: teflon
  setting environment in arcpy sunny 1 2,814 Feb-25-2019, 06:13 PM
Last Post: sunny
  ARCPY enter excel table into coded domain Just_another_lost_man 6 3,762 Feb-23-2019, 09:23 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020