I'm just getting started with Python and was following the example in: Using Feature Layers | ArcGIS for Developers
I was able to follow the example but then I tried to manipulate it to use my data. Everything was good until I got to the query. I was able to query the numerical data fine but when I tried to pull a text value I couldn't make it work.
I tried a couple different ways but the one that seems to closest (to my admittedly untrained eye) is:
query_result1 = feature_layer.query(where='recordCulvertCorrect=' "no"',
out_fields='objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter')
My guess is it has to do with the way I am trying to work with the text string but I can't see to find what I'm looking for on line. Any help is appreciated.
Solved! Go to Solution.
Hi Aaron,
Try the following:
query_result1 = feature_layer.query(where="recordCulvertCorrect='no'",
out_fields='objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter')
Hi Aaron,
Try the following:
query_result1 = feature_layer.query(where="recordCulvertCorrect='no'",
out_fields='objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter')
Just a quick guess.
query_result1 = feature_layer.query(where="recordCulvertCorrect='no'", out_fields='objectid,globalid,Date_,CulvertName,pullCulvertMaterial,pullCulvertDiameter')
That did it. Thanks!
A bit after the fact but something I like to do is create a where/select statement to a variable. This approach I use a lot because I'm always plowing through a list in a for loop:
select = 'OBJECTID = {}'.format(street_name_list[i][0])
arcpy.SelectLayerByAttribute_management("view","ADD_TO_SELECTION",select)
So the variable 'select' is the 'where clause' in select layer by attribute method:
SelectLayerByAttribute_management (in_layer_or_view, {selection_type}, {where_clause})