Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Problem with where clause and Update Cursor

$
0
0
I am working on a script that will allow users to select a project from a pull down list in the tool and then update the status. I am using an update cursor with a where clause to update the attributes for all of the polygons with the same name. When I try to run the script I get an error message that the where clause is not a string. Here is the code the where clause is in bold:

Code:

# Import arcpy and date time module
import arcpy
import datetime


# Local variables:
today = datetime.date.today()
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
parcels = arcpy.mapping.ListLayers(mxd, "Parcels", df) [0]


# Geting user input for project name, status, type, submital date and planner name
ProjectName = arcpy.GetParameterAsText(0)
ProjStatus = arcpy.GetParameterAsText(2)
SubmitDate = arcpy.GetParameterAsText(1)
DevelopeType = arcpy.GetParameterAsText(3)
PlannerName = arcpy.GetParameterAsText(4)


PlanningProjectTracking = "C:\\David Projects\\Planning Project Tracking\\PythonProjectTracking.mdb\\PlanningProjectTracking"


whereClause = "[ProjectName] = '{0}'".format(ProjectName)


#Used update cursor to create update project tracking records.
Ucursor = arcpy.da.UpdateCursor(PlanningProjectTracking, whereClause, ["PROJECTNAME","STATUS","SUBMITTALDATE","DEVELOPEMENTTYPE","PLANNER","EDITDATE"])
for row in Ucursor:
  row.setValue (ProjectName,ProjStatus,SubmitDate,DevelopeType,PlannerName,today)
  Ucursor.updateRow(row)
arcpy.RefreshActiveView()


Viewing all articles
Browse latest Browse all 2485

Trending Articles