I am currently writing some scripts to pull data down from an SDE and store it locally in a file GDB, with some fun little tweaks to "check-in" recent local edits to the feature class into the latest SDE version of the file. Everything should be fairly straightforward, as designed, but I've hit a snag very early in the process with the FeatureClassToGeodatabase_conversion results. The resulting feature class in the file GDB is always named "GPL0" instead of its original name!! Does anybody know why this is happening?I've tried this three ways:1. exporting from a layer located in an MXD. This layer points to the original SDE dataset. Result: feature class is successfully imported into the local file GDB but the feature class name is always "GPL0" instead of its original name.2. exporting from a lyr file stored locally. This lyr file points to the original SDE dataset. Result: feature class is successfully imported into the local file GDB but the feature class name is always "GPL0" instead of its original name.3. exporting from a SHP file stored locally. This SHP file was created by simple ArcMap export from the original SDE dataset. Result: feature class is successfully exported into the local file GBD maintaining its original name.Here is my problem...option 3 doesn't work for me, because creating the SHP file truncates a lot of important field names. Obviously the issue lies in exporting SDE data directly, but I don't see any way in the FeatureClassToGeodatabase process to specify a name. I can make the assumption that the export will always be named "GPL0" and then throw a Rename into the script to get it back to the original name, but that's messy and since I don't know WHY this "GPL0" stuff is happening, I can't rely on it happening forever. Any help would be appreciated!Here is the code for each method I've tried:Option 1 (layer in MXD as source)import arcpy from arcpy import mapping # set location of MXD which contains layer to be exported ExportBase = r"P:\filepath\ExportBase.mxd" # set export process variables mxd = mapping.MapDocument(ExportBase) sourceLyr = mapping.ListLayers(mxd, "data_from_SDE") outLocation = r"P:\filepath\sampleGDB.gdb" # execute export SDE layer from MXD to GDB arcpy.FeatureClassToGeodatabase_conversion(sourceLyr, outLocation)
Option 2 (lyr file pointing to SDE data as source)import arcpy from arcpy import mapping # set export process variables sourceLyr = mapping.Layer(r"P:\filepath\sampleLYR.lyr) outLocation = r"P:\filepath\sampleGDB.gdb" # execute export lyr file to GDB arcpy.FeatureClassToGeodatabase_conversion(sourceLyr, outLocation)
Option 3 (SHP file as source)import arcpy # set export process variables sourceLyr = r"C:\filepath\features.shp" outLocation = r"C:\filepath\sampleGDB.gdb" # execute export layer from SHP to GDB arcpy.FeatureClassToGeodatabase_conversion(sourceLyr, outLocation)