[GIS] Copying feature classes in feature dataset returns ERROR 000732: Input Features does not exist or is not supported

arcpycopyerror-000732feature-dataset

I'm pretty new to python and I have some trouble getting this snippet of code to work. I have some lines that work to copy shapefiles and feature classes, but I haven't managed to be able to copy feature classes from a feature dataset.

A "lookup table" exists with info on the source path, source name, target path, target name, etc.
There's a field called 'BatchID' that is used as a reference for what the user wants to be copied. That said, there's a raw input that is in the code and once the user enters the number, the data in that row(s) is copied. I keep getting the error:

ERROR 000732: Input Features: Dataset C:…file path
here…\test1.gdb\SanTest does not exist or is not supported Failed to
execute (CopyFeatures).

Copy Feature dataset- features

            if batch_id == int(btch_num):
                ds = arcpy.ListFeatureClasses('','', source_name)
                for fc in ds:
                    print ('These features') + (fc) + (' are in the feature dataset!')
                    arcpy.CopyFeatures_management(fc, os.path.join(target_path, os.path.splitext(fc)[0]))

Best Answer

I used this example in class the other night, it may offer a clue, as it works, basically copies fc out of a dataset, into a folder as shapefiles:

import arcpy

arcpy.env.workspace = "E:/class_5/ForExercise.gdb"
out = "E:/class_5/shp/"

datasets = arcpy.ListDatasets("*", "Feature")

for i in datasets:
    print i +" DataSet Name" 
    fclist = arcpy.ListFeatureClasses('*', "ALL", i)
    for x in fclist:
        print x +" fc in  Dataset"
        arcpy.CopyFeatures_management(x, out + x)

print "Done"

Your error shows a path of ..\test1.gdb\SanTest with the slashes wrong unless you used the "r" in-front of the path. Better yet just flip the slashes on your source.

(fc, os.path.join(target_path, os.path.splitext(fc)[0])) The splitext(fc)[0} is how you remove the .shp off of a shapeFile. The fc in the database probably already has this removed. Another option to define the output is path + os.sep + fc

Related Question