<?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 Re: Python Glob.Glob in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046203#M60753</link>
    <description>&lt;P&gt;List all featureclasses in a gdb.&lt;/P&gt;&lt;P&gt;Then list only those that begin with a "b"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
gdb = r"C:\arcpro_npg\npg\Project_npg\tests.gdb"
arcpy.env.workspace = gdb
fcs = arcpy.ListFeatureClasses("*")

fcs = arcpy.ListFeatureClasses("b*")

fcs = arcpy.ListFeatureClasses("*")

b_fcs = arcpy.ListFeatureClasses("b*")

fcs
['big', 'odd', 'odd_inters', 'odd_dis', 'odd_sub', 'odd5', 'odd5_centr', 'odd5_inside', 'odd_vert', 'sq', 'sq_v', 'Voronoi', 'Voronoi2', 'x2', 'multi', 'sq2', 'shps', 'v0', 'c', 'sq2_mabr', 'sq2_delaunay', 'c_pnts', 'sq_MeshPnts', 'sq2_vert', 'c_ln', 'c_segs', 'concave_c', 'c_dens', 'sq_diss', 'hex_flat', 'rectangles', 'triangles', 'hex_shift', 'dissolve', 'dissolve1', 'aoi', 'rot', 'CC', 'c0', 'c1', 'CCply', 'c0ply', 'b0b1', 'b0_b1', 'b0_b1_ints', 'b0', 'b0_ints']

b_fcs
['big', 'b0b1', 'b0_b1', 'b0_b1_ints', 'b0', 'b0_ints']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW&lt;/P&gt;&lt;P&gt;glob.glob wouldn't be able to decipher any useful filenames and/or extensions.&amp;nbsp; Examine the contents of a *.gdb using windows File Explorer and you will see what I mean&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Apr 2021 03:25:33 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-04-13T03:25:33Z</dc:date>
    <item>
      <title>Python Glob.Glob</title>
      <link>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046185#M60752</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can someone please shed some light on why my glob.glob statement is not working?&lt;/P&gt;&lt;P&gt;It works on shapefiles just not feature classes in geodatabases.&lt;/P&gt;&lt;P&gt;I am simply just trying to put in a file path to a feature class in the geodatabase. The file path however needs to include a wild card (*) as the date/name of the folder can change each month.&lt;/P&gt;&lt;P&gt;I have tried the below statement but i get the error below&lt;/P&gt;&lt;PRE&gt;TC = glob.glob(&lt;SPAN&gt;"L:/Support/Data_load/Tenements/%s/SA/Kennels/Popcorns*/Popcorn.gdb/Popcorn123" &lt;/SPAN&gt;% (d))[&lt;SPAN&gt;0&lt;/SPAN&gt;]&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;IndexError: list index out of range&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does glob.glob not support geodatabase? and if so is there another solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 01:24:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046185#M60752</guid>
      <dc:creator>Vdawg1990</dc:creator>
      <dc:date>2021-04-13T01:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python Glob.Glob</title>
      <link>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046203#M60753</link>
      <description>&lt;P&gt;List all featureclasses in a gdb.&lt;/P&gt;&lt;P&gt;Then list only those that begin with a "b"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
gdb = r"C:\arcpro_npg\npg\Project_npg\tests.gdb"
arcpy.env.workspace = gdb
fcs = arcpy.ListFeatureClasses("*")

fcs = arcpy.ListFeatureClasses("b*")

fcs = arcpy.ListFeatureClasses("*")

b_fcs = arcpy.ListFeatureClasses("b*")

fcs
['big', 'odd', 'odd_inters', 'odd_dis', 'odd_sub', 'odd5', 'odd5_centr', 'odd5_inside', 'odd_vert', 'sq', 'sq_v', 'Voronoi', 'Voronoi2', 'x2', 'multi', 'sq2', 'shps', 'v0', 'c', 'sq2_mabr', 'sq2_delaunay', 'c_pnts', 'sq_MeshPnts', 'sq2_vert', 'c_ln', 'c_segs', 'concave_c', 'c_dens', 'sq_diss', 'hex_flat', 'rectangles', 'triangles', 'hex_shift', 'dissolve', 'dissolve1', 'aoi', 'rot', 'CC', 'c0', 'c1', 'CCply', 'c0ply', 'b0b1', 'b0_b1', 'b0_b1_ints', 'b0', 'b0_ints']

b_fcs
['big', 'b0b1', 'b0_b1', 'b0_b1_ints', 'b0', 'b0_ints']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW&lt;/P&gt;&lt;P&gt;glob.glob wouldn't be able to decipher any useful filenames and/or extensions.&amp;nbsp; Examine the contents of a *.gdb using windows File Explorer and you will see what I mean&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 03:25:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046203#M60753</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-13T03:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python Glob.Glob</title>
      <link>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046235#M60754</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;Thank you for your response.&lt;/P&gt;&lt;P&gt;How do i use the feature class from the list as a variable though?&lt;/P&gt;&lt;P&gt;i.e How would i use the featureclass 'big' as variable that i can put in other commands?&amp;nbsp; (Like arcpy.addfield)&lt;/P&gt;&lt;P&gt;Also i apologise i was not clear, the wild card is not in the featureclass name but in the folder name. (what you have written is still beneficial as at some stage i will need wild cards for my feature classes)&lt;/P&gt;&lt;P&gt;TC = glob.glob(&lt;SPAN&gt;"L:/Support/Data_load/Tenements/%s/SA/Kennels/&lt;STRONG&gt;Popcorns&lt;/STRONG&gt;*/Popcorn.gdb" &lt;/SPAN&gt;% (d))[&lt;SPAN&gt;0&lt;/SPAN&gt;]&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wanting to use my feature class as a variable that i can use in addfield and other commands, but the wildcard in the folder path is causing errors"&lt;/P&gt;&lt;PRE&gt;D1 = arcpy.AddField_management(Popcorn123&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Ext_Date"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"DATE"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NULLABLE"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NON_REQUIRED"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 07:09:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046235#M60754</guid>
      <dc:creator>Vdawg1990</dc:creator>
      <dc:date>2021-04-13T07:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python Glob.Glob</title>
      <link>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046262#M60756</link>
      <description>&lt;P&gt;A wildcard used in my examples returns a list of featureclasses like glob.glob.&lt;/P&gt;&lt;P&gt;If you are using the first one, then you would slice as per usual ( [0] ).&amp;nbsp; If there was only one, then you still slice the list.&lt;/P&gt;&lt;P&gt;Or you have a list to cycle through if you are working with many featureclasses.&lt;/P&gt;&lt;P&gt;If you examined the contents of a *.gdb "folder", you will see there is no usable naming convention except through the ListFeatureClasses approach&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 07:22:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046262#M60756</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-13T07:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python Glob.Glob</title>
      <link>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046268#M60758</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ah understood!&lt;/P&gt;&lt;P&gt;Yes in my case there is only one. I have tried the index and it works like a charm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you&lt;/P&gt;&lt;PRE&gt;D1 = arcpy.AddField_management(b_fcs[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"test999"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"DATE"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NULLABLE"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NON_REQUIRED"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 07:44:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-glob-glob/m-p/1046268#M60758</guid>
      <dc:creator>Vdawg1990</dc:creator>
      <dc:date>2021-04-13T07:44:26Z</dc:date>
    </item>
  </channel>
</rss>

