I am working with a Basic license of ArcMap 10.3, and I am trying to split a feature class into multiple feature classes in a geodatabase by unique values of an attribute. More specifically, I have a feature class of locations of 78 different species, and I want to create individual feature classes for each species. I have put together some code that I have found in various places (including here), and I can get it to create all the feature classes with all the fields, but each one is empty, and I can't figure out why. I am very new to arcpy and coding in general.
# Reads the feature class for different values in the attribute cursor = arcpy.SearchCursor(inFC) row = cursor.next() attribute_values = set() strAtt = "ELCODE_BCD" print strAtt while row: attribute_values.add(row.getValue(strAtt)) row = cursor.next() # Output a Shapefile for each different attribute for each_attribute in attribute_values: # Check to see if FC exists strEmptyFC = "each_attribute" print "Checking to see if feature class exists..." if arcpy.Exists(strEmptyFC) : print strEmptyFC + " exists." else: print "Creating feature class..." outFC = strWS + "\\" + each_attribute print outFC arcpy.Select_analysis (inFC, outFC, "'%s' = 'each_attribute'" %strAtt) del strWS, inFC, cursor, row, attribute_values
I think it has to do with the where clause in the select statement.