you can check out SearchCursor method here. only one thing is that build an SQL expression instead of where_clause
. Query expressions is the same as standard SQL expressions in ArcGIS too. it is similar to Select By Attributes dialog box. you can write your own tool by looking at the following code
Summary
The SearchCursor function establishes a read-only cursor on a feature
class or table. The SearchCursor can be used to iterate through row
objects and extract field values. The search can optionally be limited
by a where clause or by field, and optionally sorted.
Syntax SearchCursor (dataset, {where_clause}, {spatial_reference},
{fields}, {sort_fields})
Example:
import arcpy
# Open a searchcursor
# Input: C:/Data/Counties.shp
# FieldList: NAME; STATE_NAME; POP2000
# SortFields: STATE_NAME A; POP2000 D
#
rows = arcpy.SearchCursor("C:/Data/Counties.shp", "'POP2000' > 5000", "", "NAME;
STATE_NAME; POP2000", "STATE_NAME A; POP2000 D")
currentState = ""
# Iterate through the rows in the cursor
#
for row in rows:
if currentState != row.STATE_NAME:
currentState = row.STATE_NAME
# Print out the state name, county, and population
#
print "State: %s, County: %s, population: %i" % \
(row.STATE_NAME, row.NAME, row.POP2000)
i hope it helps you....