1

I am trying to delete a series of files from a gdb and I am encountering suprising difficulties doing so. When I test my procedure in one of the files, let's call it 'yy.shp'This is what I do:

from arcpy import env 
from arcpy.sa import * 
import os 
env.workspace  = env.scratchWorkspace = "path/to/my/GEODB.gdb"
arcpy.Delete_management(r'yy.shp')

And I receive the error:

Runtime error Traceback (most recent call last): File "", line 1, in File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 3995, in Delete raise e ExecuteError: ERROR 999998: Unexpected Error

Notice that if I do:

arcpy.Exists(r'yy.shp')

I get a TRUE result

What am I doing wrong? I have checked and there is definitely no mistake in the path or names of the files. I got these names by dragging and dropping the gdb and file into the python console.

  • 5
    You can't delete a shapefile from a file geodatabase because you can't put a shapefile in a file geodatabase in the first place. They are different formats, and not interchangeable. It is not legal to create a FGDB table with a period in the table name. If you have used the operating system to corrupt the .gdb directory contents with a shapefile set of files, you'll need to remove them from the directory (using the OS) before you can generate a legal name for deletion. – Vince Sep 29 '18 at 17:18
1

As commented by @Vince:

You can't delete a shapefile from a file geodatabase because you can't put a shapefile in a file geodatabase in the first place. They are different formats, and not interchangeable. It is not legal to create a FGDB table with a period in the table name. If you have used the operating system to corrupt the .gdb directory contents with a shapefile set of files, you'll need to remove them from the directory (using the OS) before you can generate a legal name for deletion.

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.