Trying to figure out what the class_field variable is in this query
import arcpy
fc = 'c:/base/data.gdb/roads'
class_field = 'Road Class'
name_field = 'Name'
# Create an expression with proper delimiters
expression = arcpy.AddFieldDelimiters(fc, name_field) + ' = 2'
# Create a search cursor using an SQL expression
with arcpy.da.SearchCursor(fc, [class_field, name_field],
where_clause=expression) as cursor:
for row in cursor:
# Print the name of the residential road
print(row[1])
Solved! Go to Solution.
Please read up on cursors:
would it be easier to have a Search Cursor and WHERE clause using sql_clause?
I want to search a FC where 'Field1 = No' or 'Field2 = no'
Please read up on cursors:
yea thats where I got to example from...what the heck is class_field varaible?
ooooh....I think its looking at 2 fields and not 1 is that right?
yes
But what If I wanted classfield=Yes and name_field=No
You need to keep reading the documentation for cursors. There's a where_clause parameter where you can specify that stuff when you create the cursor.
good to bookmark ... What is ArcPy?—Help | ArcGIS for Desktop ....