I have a script that I run in ArcMap 10.5.1 that iterates through feature classes in a file geodatabase and projects each one to a WGS84 shapefile. This works smoothly for most feature classes in the geodatabase, but there is one feature class that is giving an odd error:
Traceback (most recent call last): File "E:\ProvingGrounds\SCAT\Script\SCAT Shapefile Export 02.py", line 38, in <module> arcpy.Project_management(fc, outShape, spatialRef) File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 9523, in Project raise e ExecuteError: ERROR 999999: Error executing function. The input featureclass fields and the Output fields do not have the same number of fields Failed to execute (Project).
This seems strange since arcpy.Project_management is creating the output from the input. The feature class in question is as simple as it gets, a single feature polyline with no attributes other than ObjectID and Shape_length.
Here is the script that generates the error:
import arcpy, os arcpy.env.overwrite = True scatFolder = arcpy.GetParameterAsText(0) gdb = os.path.join(scatFolder, "scatprocessing.gdb") shapeFolder = os.path.join(scatFolder, "ShapeFiles") spatialRef = arcpy.SpatialReference("WGS 1984") if arcpy.Exists(gdb): if not os.path.exists(shapeFolder): arcpy.AddMessage("\nCreating shapefile folder\n") os.makedirs(shapeFolder) arcpy.env.workspace = gdb featureClasses = arcpy.ListFeatureClasses() for fc in featureClasses: arcpy.AddMessage("Exporting " + fc + " to shapefile") outShape = os.path.join(shapeFolder, fc) arcpy.Project_management(fc, outShape, spatialRef)
The standalone Project tool in the Management Toolbox works as advertised on the same feature class using the same parameters. It is only when iterating through feature classes (to do the same thing) that it throws the error on that feature class.