1

Working with ArcGIS Desktop 10.5.1

I have a simple Python script to export all feature classes in a specific feature data set to a shapefile. It works, but it appears to duplicate the feature classes while exporting.

For example for 1 FC it produces 27 shapefiles of the same data and appends "_XX" after the name (XX is the number of duplicates)

My code is below... No idea why this is occurring, and it's 27 duplicates every time.

import arcpy


arcpy.env.workspace = r"Database Connections\Database.sde\path_to_Feature_dataset"
arcpy.env.overwriteOutput = True
rawOut = r"Y:\output folder path"

inFeatures = arcpy.ListFeatureClasses()
for feature in inFeatures:
    print "Exporting " + str(feature)
    arcpy.FeatureClassToShapefile_conversion(inFeatures, rawOut)
    print str(feature) + " Export complete! \n"
3

You used inFeatures variable in the loop. I guess you have 27 featureclass and you copy all featureclasses in every loop, so, FeatureClassToShapefile_conversion tool duplicates them 27 times.

import arcpy

arcpy.env.workspace = r"Database Connections\Database.sde\path_to_Feature_dataset"
arcpy.env.overwriteOutput = True
rawOut = r"Y:\output folder path"

inFeatures = arcpy.ListFeatureClasses()
for feature in inFeatures:
    print "Exporting " + str(feature)
    arcpy.FeatureClassToShapefile_conversion(feature, # not inFeatures
                                             rawOut)
    print str(feature) + " Export complete! \n"
  • 1
    wow, I will go lock myself in a closet now.... thanks for the help lol – NULL.Dude May 7 '18 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.