This is not a copy of previous questions like Selecting certain fields from feature class to create new feature class in ArcPy? but builds on them.
I have two approaches and two different issues.
Project: Take numerous feature classes in several SDE's and create a shapefile of each FC but only containing a selection of fields.
Method 1:
I copied the entire Feature Class to a new GDB, made a feature layer from that feature class and iterate through the layer to create a list of "delete fields" by excluding all of the already established "keep fields." I then create a new shapefile from the feature layer that deletes all fields I don't want. This works fine except when subtypes are discovered.
I wrote the following to handle subtypes:
subtypes = arcpy.da.ListSubtypes(tempLayer)
sKeys = subtypes.keys()
for keys in sKeys:
if keys != 0:
print("Subtype found at code {}.".format(keys))
sys.stdout.flush()
arcpy.RemoveSubtype_management(tempLayer,keys)
However, I still get errors saying fields cannot be deleted due to subtypes. When I look into/print the subtypes found in arcpy.da.ListSubtypes(tempLayer) ...no subtypes are found. So, with Method 1: What am I missing in identifying and deleting subtypes?