AnsweredAssumed Answered

select by attribute then export selection (script tool)

Question asked by nbaylot33 on Feb 2, 2012
Latest reply on Feb 3, 2012 by nbaylot33
This is sort of a continuation of my previous post. http://forums.arcgis.com/threads/48862-Select-by-attribute-then-exporting-selection
I would like to create a script tool that does the same thing but with user defined parameters.
import arcpy FIPS = "C:\\Users\\D2148\\Documents\\Maps\\FIPS" FIPSlist = ('001', '003', '005', '007', '009', '011', '013',          '015', '017', '019', '021', '023', '025', '027',         '029', '031', '033', '035', '037', '039', '041',         '043', '045', '047', '049', '051', '053', '055',         '057', '059', '061', '063', '065', '067', '069',         '071', '073', '075', '077', '079', '081', '083',         '085', '087', '089', '091', '093', '095', '097',         '099', '101', '103', '105', '107', '109', '111',         '113', '115', '117', '119', '121', '123', '125',         '127') for fip in FIPSlist:   query = "FIPS_PARIS ='" + fip + "'"   arcpy.TableSelect_analysis("Master_TAHI", FIPS + "\\FIPS" + fip + ".dbf",query)


This is the original script that works, I just need it to take user defined parameters and I have never created a tool.

- It needs an input dbase, feature class or shapefile (eg. "Master_TAHI")
- A list of attributes the tool needs to loop through (eg. fips = ('001', '003', '005')
- The sql clause (eg. "FIPS_PARIS ='" + fip + "'")
- output with name of attribute at end. (eg. "\\FIPS" + fip + ".dbf")

Outcomes