Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

UpdateCursor gives Too few parameters Expected 1?

$
0
0

Can anyone tell me why my script isnt working?

I cant figure out where I went wrong. I am working with an access personal geodatabase. Adding a field, then updating that field with yes if the field Surface_Cover equals CONCRETE, or else it returns NO.

I am getting an error message “Too few parameters. Expected 1″.

#import tools and set workspace
import os
import arcpy

arcpy.env.workspace = "C:UserssuttonDocumentsPythonPythonExcercise/PlanoData.mdb"

try:

    #create new field to hold new values
    arcpy.AddField_management("SmokeMain","Indicator","TEXT","10")
    print("Indicator field added to SmokeMain")
    with arcpy.da.UpdateCursor("SmokeMain",("Surface_Cover","Indicator")) as cursor:
        cntr = 1
        for row in cursor:
                #update the indicator field
                if row[0] == "CONCRETE":
                        row[1] = "YES"
                else:
                        row[1] = "NO"
                cursor.updateRow(row)
                print ("Record number " +str(cntr) + " updated")
                cntr = cntr + 1
#error checking
except Exception as e:
    print(e.message)

#script status
ScriptStatus = "Script executed"
print ScriptStatus

Viewing all articles
Browse latest Browse all 767

Latest Images

Trending Articles



Latest Images