<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to get the dataset name from feature class name using arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1588968#M73793</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a list of geodatabase feature class names and I would like to have the dataset names for each if any.&lt;/P&gt;&lt;P&gt;Ideally I would prefer not to loop over each element of the geodatabase to find it. I was hoping arcpy.Describe would contain that information, but no.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os, arcpy

workspace = "path/to/geodatabase.gdb"
fc_list = ["fc_1_name", "fc_2_name", "fc_3_name"]

for fc in fc_list:
  desc = arcpy.Describe(os.path.join(workspace, fc))

  print(desc.catalogPath) #does not includes dataset if any&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion would be appreciated!&lt;BR /&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 25 Feb 2025 15:35:30 GMT</pubDate>
    <dc:creator>MaximeDemers</dc:creator>
    <dc:date>2025-02-25T15:35:30Z</dc:date>
    <item>
      <title>How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1588968#M73793</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a list of geodatabase feature class names and I would like to have the dataset names for each if any.&lt;/P&gt;&lt;P&gt;Ideally I would prefer not to loop over each element of the geodatabase to find it. I was hoping arcpy.Describe would contain that information, but no.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os, arcpy

workspace = "path/to/geodatabase.gdb"
fc_list = ["fc_1_name", "fc_2_name", "fc_3_name"]

for fc in fc_list:
  desc = arcpy.Describe(os.path.join(workspace, fc))

  print(desc.catalogPath) #does not includes dataset if any&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion would be appreciated!&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 15:35:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1588968#M73793</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2025-02-25T15:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1588995#M73794</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/118250"&gt;@MaximeDemers&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Have you looked into &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/listdatasets.htm" target="_blank" rel="noopener"&gt;List Datasets&lt;/A&gt;&amp;nbsp;or&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/walk.htm" target="_self"&gt;Walk&lt;/A&gt; for that matter.&lt;/P&gt;&lt;P&gt;That should help guide you to identify the list of datasets, but if you are looking to get the list of datasets using the feature class filepath then here is a sample below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
Workspace = '&amp;lt;some sde or gdb&amp;gt;'
Walk = arcpy.da.Walk( Workspace , datatype="FeatureDataset" )
for root, dirname, filenames in Walk:
    print( dirname )
    for filename in filenames:
         print( '&amp;lt;something&amp;gt;' )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 16:32:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1588995#M73794</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-02-25T16:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589061#M73795</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/118250"&gt;@MaximeDemers&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Multiple ways to achieve this and you can still go down the Describe route.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

workspace = "path/to/geodatabase.gdb"
fc_list = ["fc_1_name", "fc_2_name", "fc_3_name"]

## describe the gdb
desc = arcpy.da.Describe(workspace)

## use dictionary comprehension
## if fc name is forund in a Feature Dataset and entry is made in the dictionary
## FC_NAME (key) : FD_NAME (value)
fc_dict = {fc["name"]: fd["name"] for fd in desc["children"] if fd["dataType"] == "FeatureDataset" for fc in fd["children"] if fc["name"] in fc_list}

print(fc_dict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this help?&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 18:14:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589061#M73795</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-02-25T18:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589121#M73796</link>
      <description>&lt;P&gt;There is not a good way.&lt;/P&gt;&lt;P&gt;Please vote on this related Idea here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/feature-classes-add-property-denoting-whether-it-s/idi-p/1553518" target="_blank"&gt;Feature Classes: Add Property denoting whether it'... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Couple things here, though.&lt;/P&gt;&lt;P&gt;Feature Datasets don't exist. You think they do, we pretend they do, but for most operations you use, you can plug in "C:\test.gdb\ExFD\exFC" OR "C:\test.gd\exFC" and get the same result. Try it on Buffer()&amp;nbsp; or Exists() if you don't believe me.&amp;nbsp; Where we run into problems is when we're actually trying to search for stuff, and&amp;nbsp;&lt;EM&gt;then&lt;/EM&gt; Pro thinks that they matter for some reason.&lt;/P&gt;&lt;P&gt;Because of this, the way you're going about this is kind of self-defeating because Describe() will take the path with or without the dataset in there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best way to do this is, unfortunately, to set the workspace environment and search through there. Something like this (I wrote this from memory so idk if the capitalization is right)&lt;/P&gt;&lt;LI-CODE lang="c"&gt;fdDict = {} # {fd1: [fcA, fcB], fd2:[fcC, fcD]}

gdb = r"...\ex.gdb"

arcpy.env.workspace = gdb

for fd in arcpy.ListDatasets("Feature"):
    fdDict[fd] = []
    arcpy.env.workspace = os.path.join(gdb, fd)
    for fc in arcpy.ListFeatureClasses():
        fdDict[fd].append(fc)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please also vote on this Idea to make iterating through these workspaces less awful:&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-ideas/arcpy-list-type-functions-let-us-feed-it-a/idi-p/1529687" target="_blank"&gt;arcpy.List[Type] functions: Let us feed it a works... - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 19:57:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589121#M73796</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-02-25T19:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589122#M73797</link>
      <description>&lt;P&gt;Thank you for your answer!&lt;BR /&gt;&lt;BR /&gt;If I have no choice but to loop over datasets, this is how I do:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os, arcpy

workspace = "path/to/geodabase.gdb"
arcpy.env.workspace = workspace 
datasets = arcpy.ListDatasets()
fc_list = ["fc_1_name", "fc_2_name", "fc_3_name"]
for fc in fc_list:
  dataset = next((dataset for dataset in datasets if arcpy.Exists(os.path.join(workspace, dataset, fc)), None)
  print(dataset, fc)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Feb 2025 20:05:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589122#M73797</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2025-02-25T20:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589237#M73801</link>
      <description>&lt;P&gt;You can find the dataset using some Path magic too:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from __future__ import annotations
from pathlib import Path
from arcpy import Describe

# For Describe type hinting
try:
    from arcpy.typing.describe import FeatureClass
except ImportError: # will fail at runtime do to malformed package
    pass

def get_fc_dataset(fc: Path) -&amp;gt; str:
    fc = Path(fc)
    fc_desc: FeatureClass = Describe(str(fc))
    fc_dataset = fc.parent
    wsp_path = Path(fc_desc.workspace.catalogPath)
    if fc_dataset != wsp_path:
        return str(fc_dataset.relative_to(wsp_path))&lt;/LI-CODE&gt;&lt;P&gt;Because the workspace of a feature class doesn't include the Dataset it belongs to, you can get the relative component of the featureclass parent and the workspace. Basically all this does is remove the FC name from the path and then check for the part of that parent path that isn't in the workspace.&lt;/P&gt;&lt;P&gt;This function currently returns the name of the dataset, but you could also have it return the full path by just returning the fc_dataset.&lt;/P&gt;&lt;P&gt;Here's Alfred's code written as a function with the same return result as this one:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcpy import Describe, ListDatasets, EnvManager

def get_fc_dataset_list(fc: str) -&amp;gt; str:
    fc_desc: FeatureClass = Describe(fc)
    with EnvManager(workspace=fc_desc.workspace.catalogPath):
        for ds in ListDatasets():
            if ds in fc:
                return ds&lt;/LI-CODE&gt;&lt;P&gt;I slightly modified it to use an EnvManager so you don't leave your environment in a dirty state.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When timing these, the Path solution is a little bit faster:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;gt;&amp;gt;&amp;gt; %timeit get_fc_dataset(path)
35 ms ± 836 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

&amp;gt;&amp;gt;&amp;gt; %timeit get_fc_dataset_list(path)
49.4 ms ± 1.1 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if you wrap the functions in a functools.lru_cache decorator, they both perform incredibly fast:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from __future__ import annotations
from pathlib import Path
from arcpy import Describe, ListDatasets, EnvManager
from functools import lru_cache

# For Describe type hinting
try:
    from arcpy.typing.describe import FeatureClass
except ImportError: # will fail at runtime do to malformed package
    pass

@lru_cache
def get_fc_dataset(fc: Path) -&amp;gt; str:
    fc = Path(fc)
    fc_desc: FeatureClass = Describe(str(fc))
    fc_dataset = fc.parent
    wsp_path = Path(fc_desc.workspace.catalogPath)
    if fc_dataset != wsp_path:
        return str(fc_dataset.relative_to(wsp_path))

@lru_cache
def get_fc_dataset_list(fc: str) -&amp;gt; str:
    fc_desc: FeatureClass = Describe(fc)
    with EnvManager(workspace=fc_desc.workspace.catalogPath):
        for ds in ListDatasets():
            if ds in fc:
                return ds
    &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;gt;&amp;gt;&amp;gt; %timeit get_fc_dataset(path)
79.9 ns ± 0.512 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

&amp;gt;&amp;gt;&amp;gt; %timeit get_fc_dataset_list(path)
79.6 ns ± 0.31 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need to access datasets a lot (see, repeatedly calling this in a loop somewhere with the same arguments each time), using the lru_cache is probably a good idea. Just make sure to invalidate it with func.cache_clear() if you add a new dataset or move a feature from one dataset to another.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 00:18:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589237#M73801</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-02-26T00:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589430#M73803</link>
      <description>&lt;P&gt;ok thank you, but as I said in the post, I just have the featureClass names, not the path with the dataset. Of course, if I did have the complete path, I could use pathlib or os.path to retreive the dataset from it.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 13:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589430#M73803</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2025-02-26T13:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589444#M73804</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/walk.htm" target="_self"&gt;Walk - ArcGIS Pro | Documentation&lt;/A&gt; is more functional, idiomatic, and performant then relying on the older ArcPy List functions.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 14:06:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589444#M73804</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-02-26T14:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589801#M73811</link>
      <description>&lt;P&gt;You're right, I misread your post and thought you needed to extract the dataset from the featureclass you already had.&lt;/P&gt;&lt;P&gt;As Alfred showed you need to mess with the environment and dataset to get a mapping with just a gdb path.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a wrapper class I use for this documented in &lt;A href="https://community.esri.com/t5/python-snippets-blog/a-simple-drop-in-class-for-managing-workspaces/ba-p/1587120" target="_self"&gt;this blog post&lt;/A&gt; if that's something that would interest you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It turns the confusing and tedious process of mutating the environment into something that's more modular.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 22:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589801#M73811</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-02-26T22:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589804#M73812</link>
      <description>&lt;P&gt;da.Walk is such a powerful tool, but it's irritating how slow it can be. Because it's recursively extracting the structure from the root, it can sometimes take seconds to run when passed a moderately complex workspace.&lt;/P&gt;&lt;P&gt;This isn't a big deal when you are only running it once, but I frequently have tools that need to get their context on initialization, and if you have say 10 tools in a toolbox that all call da.Walk, that can sometimes mean loading the toolbox in will take 10-15 seconds.&lt;/P&gt;&lt;P&gt;Again, not the worst if you absolutely need all that info, but it's a recipe for people thinking things are broken when the toolbox loading in locks the main thread for a long time with no clear reason as to what's happening.&lt;/P&gt;&lt;P&gt;This also happens with the Python Window when it processes auto-complete options for your current cursor position. Because it's trying to find out the short names of the layers you can put in to a function call, it will just hang the main thread until it finds them, then hang it again if you move your cursor.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 22:43:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589804#M73812</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-02-26T22:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589849#M73815</link>
      <description>&lt;P&gt;When you need to walk a whole directory, it can be faster. However it seems that if all you already know what you want, the List functions can be faster:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a test where I'm pulling all the feature class names from the root of the workspace:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcpy.da import Walk
from arcpy import EnvManager, ListFeatureClasses

def test_list(workspace: str):
    fcs = []
    with EnvManager(workspace=workspace):
        fcs.extend(ListFeatureClasses())
    return fcs

def test_walk(workspace: str):
    fcs = []
    for root, dirs, files in Walk(workspace, datatype='FeatureClass'):
        fcs.extend([f for f in files])
    return fcs&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; %timeit test_list(wsp)
18.7 ms ± 80.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

&amp;gt;&amp;gt;&amp;gt; %timeit test_walk(wsp)
112 ms ± 1.55 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you have to do a recursive dataset traversal, Walk edges out the List workflow:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def test_list(workspace: str):
    fcs = []
    with EnvManager(workspace=workspace):
        fcs.extend(ListFeatureClasses())
        for ds in ListDatasets():
            fcs.extend(ListFeatureClasses(feature_dataset=ds))
    return fcs

def test_walk(workspace: str):
    fcs = []
    for root, dirs, files in Walk(workspace, datatype='FeatureClass'):
        fcs.extend([f for f in files])
    return fcs&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;&amp;gt;&amp;gt;&amp;gt; %timeit test_list(wsp)
184 ms ± 1.88 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

&amp;gt;&amp;gt;&amp;gt; %timeit test_walk(wsp)
111 ms ± 814 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, the List functions are going to change in execution time depending on how you end up using them, while Walk will be pretty consistent. 1/10th of a second for a GDB with ~75 Feature Classes and 4 FeatureDatasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do agree with it being more idiomatic, though it can be a bit confusing, for example if you want to pull datasets from a project workspace with multiple GDBs, you need to do this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for root, dirs, files in Walk(self.path, datatype=datatype):
            if 'Dataset' in datatype:
                # add some filtering so only dirs after a .gdb are added
                # without this all directories are considered datasets
                paths.extend([Path(root) / d for d in dirs if root.endswith('.gdb')])
            else:
                paths.extend([Path(root) / f for f in files])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because the 'FeatureDataset' datatype will return all empty directories in the root recursively. So you need to filter on the root and make sure it's in a gdb or you'll get all the folders...&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 00:42:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1589849#M73815</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-02-27T00:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1590115#M73819</link>
      <description>&lt;P&gt;I tested your code on several file and mobile geodatabases on my machine, and the Walk code was almost an order of magnitude faster for all cases.&amp;nbsp; I am not sure why it is slower in your tests on your machine.&amp;nbsp; Can you run the tests not using a Notebook.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 15:41:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1590115#M73819</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2025-02-27T15:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the dataset name from feature class name using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1590170#M73820</link>
      <description>&lt;P&gt;If you already have the file paths for the feature class then you can simply use o.path.split(filepath)[0] to get the dataset. Datasets are generally treated like subfolder in gdbs and sdes. You can check if the file path is a dataset vs an .sde or .gdb by simply checking if those exists at the end of the file path.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 16:39:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-get-the-dataset-name-from-feature-class/m-p/1590170#M73820</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-02-27T16:39:23Z</dc:date>
    </item>
  </channel>
</rss>

