Select to view content in your preferred language

Arcpy Select By Attribute

34
0
3 hours ago
jbrower
New Contributor III

I have some code I wrote out that creates a grid index from a selection in a layer. However, I just recently upgraded from Pro 3.2 to Pro 3.3 and now the select by attribute doesn't seem to work in the code at all. Here is the original code with layer being a layer in the map and field and attribute as text values. 

            arcpy.management.SelectLayerByAttribute(
                in_layer_or_view=layer,
                selection_type="NEW_SELECTION",
                where_clause="{0} = '{1}'".format(field, attribute),
                invert_where_clause=None
            )
 
I haven't changed the code and looking at the documentation on it, the code should work, but it isn't. Any suggestions would be great!
 
I did also try this:
 
filter = "{0} = '{1}'".format(field, attribute)
            arcpy.management.SelectLayerByAttribute(layer,"NEW_SELECTION",filter)
 
And unfortunately that didn't work either.
0 Kudos
0 Replies