AnsweredAssumed Answered

Search Cursor

Question asked by jay.kapalczynski on Nov 18, 2016
Latest reply on Nov 19, 2016 by curtvprice

Trying to figure out what the class_field variable is in this query

 

  • fc is the Feature Class
  • Class_field is WHAT?
  • name_field is the field value?

 

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])

Outcomes