PrelimSelectByCOFIPS = ["Database Connections\NC_FLOOD.sde\NC_FLOOD.DBO.BASE\NC_FLOOD.DBO.S_POL_AR", "Database Connections\NC_FLOOD.sde\NC_FLOOD.DBO.BASE\NC_FLOOD.DBO.S_COMMUNITY_GROUP", "Database Connections\NC_FLOOD.sde\NC_FLOOD.DBO.FLOOD\NC_FLOOD.DBO.V_P_FLD_HAZ_AR", "Database Connections\NC_FLOOD.sde\NC_FLOOD.DBO.FLOOD\NC_FLOOD.DBO.V_P_FLD_HAZ_LN", "Database Connections\NC_FLOOD.sde\NC_FLOOD.DBO.FLOOD\NC_FLOOD.DBO.V_P_HYDRAMODEL"]
# Select Features by COFIPS
arcpy.AddMessage("Selecting by COFIPS")
CLAUSE = ('{0} = {1}'.format ("CO_FIPS", COFIPS))
for feature in PrelimSelectByCOFIPS:
outfeaturename = string.join(feature.rstrip().split('.')[-1:],'.')
arcpy.AddMessage("Selecting " + outfeaturename)
featurelayer = os.path.join(FRIS_FGDB, outfeaturename + "_layer")
COFIPSfeature = os.path.join(FRIS_FGDB, outfeaturename)
arcpy.MakeFeatureLayer_management(feature, featurelayer)
arcpy.SelectLayerByAttribute_management (featurelayer, "NEW_SELECTION", CLAUSE)
arcpy.CopyFeatures_management(featurelayer, COFIPSfeature)
arcpy.Delete_management(featurelayer)Solved! Go to Solution.
# This appears to be in error- 'field_name' is used twice in the expression: sql_exp = """{0} = {1}""".format( arcpy.AddFieldDelimiters('c:/data', field_name), field_name) # ...should likely be 'state_value', the only unused parameter. # Also, note this would only work for numerical fields; txt fields would be: # """{0} = '{1}'""" so on and so forth... sql_exp = """{0} = {1}""".format( arcpy.AddFieldDelimiters('c:/data', field_name), state_value)# This appears to be in error- 'field_name' is used twice in the expression: sql_exp = """{0} = {1}""".format( arcpy.AddFieldDelimiters('c:/data', field_name), field_name) # ...should likely be 'state_value', the only unused parameter. # Also, note this would only work for numerical fields; txt fields would be: # """{0} = '{1}'""" so on and so forth... sql_exp = """{0} = {1}""".format( arcpy.AddFieldDelimiters('c:/data', field_name), state_value)