In my last post I had an issue where I wanted to create multiple shapefiles based on only one attribute field (years). How to do it was answered in that post. I want to make that tool more dynamic so that the user can select any field and any value and make a shapefile for it. Any suggestions on how to use the tool dynamic so that fields and the operator(<,<=,=,>,>=) can also be defined by the user itself.
I tried the following:
import arcpy fc = arcpy.GetParameterAsText(0) yrs = arcpy.GetParameterAsText(1) yrs = yrs.split(';') subtract = '' for yr in yrs: where = '"arcpy.GetParameterAsText(3)" arcpy.GetParameterAsText(2) ' + str(yr) + subtract subtract = ' AND "arcpy.GetParameterAsText(3)" > ' + str(yr) filename = str(arcpy.GetParameterAsText(3)) + '.shp' arcpy.FeatureClassToFeatureClass_conversion(fc, "arcpy.GetParameterAsText(4)", filename, where) del yr
I get the following error message: : ERROR 999999: Error executing function. An invalid SQL statement was used. An invalid SQL statement was used. Failed to execute (FeatureClassToFeatureClass).
Also attaching the screenshot for properties while adding the script.
ogr2ogr NewFile.shp Template.shp -where "FID < 0"