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

SelectLayerByAttribute using an 'in' argument

$
0
0
I'm trying to build a dynamic query that addresses user section of multiple values.

example: User input might be 1 or 1,2,3 or 1-5

I thought I could build a query such as

Code:

myfield = arcpy.AddFieldDelimiters(layer,"Number")

value = code to create an create an input list()
>>> value
[1, 2, 3, 4, 5, 6]

iQuery = '{0} in {1}'.format(value,myfield)

arcpy.SelectLayerByAttribute_management(layer,"NEW_SELECTION",iQuery)

Getting an 'Invalid expression Failed' error

Am I barking up the wrong tree with my methodology?

Thanks

Viewing all articles
Browse latest Browse all 2485

Trending Articles