Trying to parse out part of a SDE feature class name to be copied into new GDB

2070
2
07-09-2015 10:57 AM
NicoleFrankenfield
New Contributor

Hello. I'm working on a script that (among other things) needs to parse out all the SDE-like text of a feature class name to leave just the individual fc name at the end of the fullname (i.e. Database Connections\Connection to blahblah.sde\SampleDB.SDE.Communications\SampleDB.SDE.Cameras needs to called Cameras).

I've been searching ArcGIS Resources and find ways to edit field names, but could use some help...

Thanks in advance!

0 Kudos
2 Replies
ZachMahan
New Contributor

I copy SDE feature classes into file GDB's using a script I generated with Model Builder and all the SDE nomenclature is automatically dropped. You could try generating a snip it using feature class to feature class in Model Builder and use it in your script. I don't generally script from scratch but I know this has worked for me.

0 Kudos
DavidStockdale
New Contributor II

You might try something like this:

import arcpy,os

wksp = # your SDE connection

arcpy.env.workspace = wksp

output = # your output geodatabase or folder

fc = # feature class to convert

base = os.path.basename(fc)

b = base.split(".")  # splits on the periods

b1 = len(b)

b2= b[b1 - 1] # gets the last string which should be the name you want)

arcpy.FeatureClassToFeatureClass_conversion(fc,output,b2)

0 Kudos