I am trying to use an UpdateCursor fill in a field but I keep getting an error, can anyone tell me what I am doing wrong? My code is below:
import arcpy
fc= "C:\Users\Keri\Desktop\GEP_690\Project Data\FINAL_PROJECT.gdb\NYC_Demographics_2010"
with arcpy.da.UpdateCursor(fc, ["Total1","White","Pct_White"]) as cursor:
for field in cursor:
if field[0]==0:
field[2]=0
else:
field[2] = field[1] / field[0]
cursor.updateRow([field])
print "Complete."
del row
del cursor
This is the error I keep getting:
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\GEP_662\Lab9.py", line 15, in <module>
cursor.updateRow([field])
TypeError: sequence size must match size of the row
del row
anddel cursor
are not needed when using a cursor in awith
statement.