raw_input in Select_analysis?

354
2
03-30-2011 10:03 AM
RyanCooper
New Contributor
I'm working on a simple suitability analysis project for my GIS programming class wherein raw_inputs iare used to define part of the where_clause in Select_analysis. Here is what I have so far:

import arcpy
arcpy.env.workspace=r"I:\GIS\Test.mdb"
EL1=raw_input('Enter name of elementary school')
arcpy.Select_analysis('SchoolDistrictsElementary',r'I:\GIS\Output.mdb\school'+'_'+'EL1','[NAME]=EL1')

When I run the script, I get the following error:
General function failure [SchoolDistrictsElementary]
Too few parameters. Expected 1.
Failed to execute (Select).


I've tried everything I could think of, although my Python-fu is pretty weak. Nonetheless, this seems like on of those cases when the answer is right under my nose. Any thoughts on how to fix this issue? Thanks!
Tags (2)
0 Kudos
2 Replies
StevenArebalo
New Contributor
import arcpy
arcpy.env.workspace=r"I:\GIS\Test.mdb"
EL1=raw_input('Enter name of elementary school')
outFeatureClass='I:\GIS\Output.mdb\school_'+EL1
whereString='[NAME]="'+EL1+'"'
arcpy.Select_analysis('SchoolDistrictsElementary',outFeatureClass,whereString)

In your original code, the variable EL1 was read as a string instead of it's value in your WHERE clause. I haven't ran the code, but this should work. Hope this helps.

edited due to misreading OP
0 Kudos
RyanCooper
New Contributor
Thanks for your reply. I couldn't quite get that to work. It would return an error that there was a missing operator for:
whereString='I:\GIS\Output.mdb\school_'+EL1+',[NAME]="'+EL1+'"'

Anyway, I adjusted my project a little bit so it's not so important that I have this element to it. Nonetheless, thank you again for your help!
0 Kudos