Retrieving features from a feature class with a SearchCursor
There are many occasions when you need to retrieve rows from a table or feature class for read-only purposes. For example, you might want to generate a list of all land parcels in a city with a value of greater than $100,000. In this case, you don't have any need to edit the data. Your needs are met simply by generating a list of rows that meet some sort of criteria.
Getting ready
The SearchCursor()
function is used to return a SearchCursor
object. This object can only be used to iterate through a set of rows returned for read-only purposes. No insertions, deletions, or updates can occur through this object. An optional where
clause can be set to limit the rows returned. In this recipe, you will learn how to create a basic SearchCursor
object on a feature class through the use of the SearchCursor()
function.
The SearchCursor
object contains a fields
property along with next()
and reset()
methods. The fields
property is a read-only...