AnsweredAssumed Answered

Selecting by Attribute - help

Question asked by IlanGoichman on Aug 21, 2012
Latest reply on Aug 21, 2012 by IlanGoichman

Im trying to write a code that will be used as a tool on arcgis. The user will have to insert the number of a Block and the Number of a Parcel in 1 shapefile and the tool will create a JPEG map of the Block and Parcel.

The 1st thing i need to do is to select the correct Parcel and Block (Gush = Block, Helka = Parcel). The field for Gush in the shapefile is "GUSH_NUM", and the field for Helka is "Parcel"

So both Gush and Helka will have to be arcpy.GetParameterAsText, and using a variable in the where clause of the select by attribute tool.

But how do i write it in the where clause of the select by attribute tool? 

I tried using this post for help:

So i tried writing the where clause as the post suggests but it still doesnt work. I get an error - invalid expression.

Here is my code so far, i tried only on the Gush for now. 

Will apriciate any help. :-)

# Import the arcgisscripting module. import arcpy  # Setting the Variabls.  # Input gush and Helka. Gush = arcpy.GetParameterAsText(0) Helka = arcpy.GetParameterAsText(1)  # Output Location (the folder where the resualt will be saved). Workspace = arcpy.GetParameterAsText(2)  arcpy.env.workspace = Workspace   hel_openland_shp = "W:\\Av_data\\cover_new\\mamag_mapi\\hel_openland.shp" Output_Layer = "hel_openland_Layer"  arcpy.MakeFeatureLayer_management(hel_openland_shp, Output_Layer)  arcpy.SelectLayerByAttribute_management(Output_Layer, "NEW_SELECTION", "\"GUSH_NUM\" = " + "'" + Gush + "'")