Using Pyscripter to take the last 5 characters (the ZIP code) of an address field and putting that into a separate field.
I am getting the following error:
File "C:\Users\battl\Desktop\experiment.py", line 21, in <module>
zipCursor.updateRow([zipRow])
TypeError: fields size must match size of the row
When I google it, it's saying that the zipRow at the end needs to be designated as a list (thus the square brackets, it doesn't work with or without them)
Here's my code:
import arcpy
arcpy.env.workspace = r"C:\GIS\VoteTally"
gdbTable = "\\Voters.gdb\\voterRecords"
addressField = "RESIDENTIAL_ADDRESS__CITY_STATE_ZIP"
zipField = "ZIP"
with arcpy.da.UpdateCursor (gdbTable, (addressField, zipField)) as zipCursor:
for zipRow in zipCursor:
street = zipRow[0]
zipCode = street[-5:]
zipRow = zipCode
zipCursor.updateRow([zipRow])
Any help would be greatly appreciated.