I wrote a tool script using python that collects a couple of feature classes (from different Feature data sets in the same gdb) as several GetParameterAsText.
When I now want to start editing I figured out that it requires to address the gdb and not the Feature data set (or the feature class). But all methods I found until now refer to the feature data set.
like
os.path.split(_polygonfeature)[0]
or
os.path.dirname(_polygonfeature)
Isn't there a way to call the gdb that contains the feature class/feature data set?
Thanks in advance!
I believe there is arcpy method that does this but an easy way is to search the string for the .gdb.
strTest = r"C:\WorkDoc\Default.gdb\myDataset\myFeatureClass"
pathGDB = strTest[:strTest.index('.gdb')+4]
print pathGDB
Thanks Kevin, this is at least a solution.
I still also believe that there must be an arcpy method...
Thanks for the hint Dan, but for me the catalogPath gives the full path to the feature class and not only the gdb.
Also baseName is giving the feature class (without the path).
Slice and splice...
cp = r"C:\Git_Dan\a_Data\testdata.gdb\square2" # ---- catalogPath result -----
to_cp = "\\".join(cp.split(".")[0].split("\\")[:-1]) #---- split, slice, split, slice
to_cp
'C:\\Git_Dan\\a_Data'
Yes, that goes in the same direction as Kevin's solution. I still think there must be a property somewhere storing the gdb automatically...
a gdb is essentially a folder, so 'os.path' isn't going to be much help either