ARCPY using the arcpy.da.UpdateCursor - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: ARCPY using the arcpy.da.UpdateCursor (/thread-454.html) |
ARCPY using the arcpy.da.UpdateCursor - CornJulio - Oct-12-2016 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 Thanks Leith
RE: ARCPY using the arcpy.da.UpdateCursor - wavic - Oct-12-2016 Insert a print() under the for loop and see why is that ....... for row in cursor: print(row[0]) leftPart = (rowCount % 4) + 1 ..... RE: ARCPY using the arcpy.da.UpdateCursor - CornJulio - Oct-12-2016 SO this is ther Error I get now: it appears to have added to the Table only the Values 1B and 1 C. No 1A
|