AnsweredAssumed Answered

Using Variable for Where Clause in search cursor

Question asked by ryanptucker on Mar 30, 2015
Latest reply on Jun 15, 2015 by geoid23

How do I go about using a variable from a raw_input for the where clause in da.SearchCursor?

I can't seem to get the syntax correct

 

Code:

 

import arcpy
from arcpy import env
env.workspace=r"F:\GEOG_488\Final_Project_Data\FinalProject488.gdb"
fc="PARCELS" #Create variable for feature class
tc="ADDRESS_TEST_20"  #Create variable for table

 

HouseNumber = int(raw_input("Enter Address Number: ")) #User input House Number
print "Situs Addresses with "+ str(HouseNumber)+" for the Situs Number:"


cursor = arcpy.da.SearchCursor(tc,["ADDR"],'"SA_House_Number"= HouseNumber') #Create search cursor where records = HouseNumber
for row in cursor:
    print "Situs Address with House Number"+str(HouseNumber)":",row[0]

del row, cursor

 

Thanks for any help.

Outcomes