AnsweredAssumed Answered

Create new feature classes from attribute: select analysis

Question asked by rgthurau on Sep 23, 2012
Latest reply on Sep 24, 2012 by rgthurau
Hi,
I'm having a hard time getting the syntax down for a simple script. I have a single feature class with a field called "Grid_Num". Grid_Num is a numeric with values 1 - 12. I want my script to loop through the feature class and create 12 new feature classes based on, and named with Grid_Num value.

gridlist = range(1, 13) for i in gridlist:     arcpy.Select_analysis(InGrid, ws + "/" + "ProcGridbuf_" + str(i), "\"Grid_Num\ = %d"%(i))


Error Message:
Traceback (most recent call last):
  File "E:\Tools\Cal_IMG_prj_resample.py", line 42, in <module>
    arcpy.Select_analysis(InGrid, ws + "/" + "ProcGridbuf_" + str(i),"\"Grid_Num\ = %d"%(i))
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\analysis.py", line 88, in Select
    raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used.
The table was not found. [ProcGridbuf_1]
Failed to execute (Select).

1. What do I need to do to get this thing to work? - Confusing part to me is mixing Python and the ArcGIS query.
2. Can someone help my non-programming brain about what the \ and % are doing? - Probably why I can't get this to run :)

Thanks

Rich

Outcomes