AnsweredAssumed Answered

Help with Expression Syntax with two variables - SelectLayerByAttribute.

Question asked by jplay on Jun 7, 2013
Latest reply on Jun 7, 2013 by jplay
I am trying to create and expression that uses the value of the ELEVATION field in a feature class to select out a single feature and export it to its own feature class; essentially "ELEVATION" = 3 where the value '3' is a variable.

Needless to say, I'm having difficulty with the expression--I don???t have a firm grasp on the whole "\""  thing.

Here's what I have at the moment.

field = "ELEVATION" cursor = arcpy.SearchCursor(GAGELayer) for row in cursor:     ElValue = float(row.getValue(field))     exp = "\"" + field + "\" = " + GridValue + ""\"     arcpy.SelectLayerByAttribute_management (GAGEMergeLayer, "NEW_SELECTION", exp)

I get it if '3' was a constant. (I'm not real clear what "\"" means exactly. does "\"" = "" or = "? And how do you reverse it for the end of an expression?)

Something like this

exp = "\"" + field + "\" = 3"

I'm not sure how to take that and make the expression work with '3' as a variable.

Any help (and a little explanation) would be greatly appreciated.