<?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: ListFeatureClasses python script truncating features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298880#M23144</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm also not sure where and why the name should be truncated. However, I would suggest to use arcpy.da.Walk(), simply because you do not have to start over and over again to find all the feature classes within the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14128744583973969 jive_text_macro" jivemacro_uid="_14128744583973969"&gt;
&lt;P&gt;import arcpy, os&lt;/P&gt;
&lt;P&gt;f = open('C:/temp/fc_list.txt', 'a')&lt;/P&gt;
&lt;P&gt;arcpy.env.workspace = r'C:/temp/Tracks.gdb'&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for dirpath, dirnames, filenames in arcpy.da.Walk(arcpy.env.workspace, datatype='FeatureClass'):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_path = os.path.join(dirpath, filename)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(fc_path + '\n')&lt;/P&gt;
&lt;P&gt;f.close()&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't need the complete path skip line 7 and exchange 'fc_path' in line 8 by 'filename'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Oct 2014 17:13:59 GMT</pubDate>
    <dc:creator>TomGeo</dc:creator>
    <dc:date>2014-10-09T17:13:59Z</dc:date>
    <item>
      <title>ListFeatureClasses python script truncating features</title>
      <link>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298878#M23142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found an arcpy script for exporting all feature classes within a geodatabase, however, it is truncating the names to 26 character max. Features can be up to 160 characters, though the most I have is maybe 40 ... thanks end users. How do I get the full name out of the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;ebay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14127881383508862" jivemacro_uid="_14127881383508862"&gt;
&lt;P&gt;import arcpy&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;# create or open an existing text file&amp;nbsp; &lt;/P&gt;
&lt;P&gt;f = open("c:\\temp\\fc_list.txt", "a")&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;# specify the geodatabase you want to retrieve feature classes from&amp;nbsp; &lt;/P&gt;
&lt;P&gt;gdb = "c:\\temp\\Tracks.gdb"&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;# set your environment workspace&amp;nbsp; &lt;/P&gt;
&lt;P&gt;arcpy.env.workspace = gdb&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;#list all of the feature datasets within the geodatabase&amp;nbsp; &lt;/P&gt;
&lt;P&gt;datasetList = arcpy.ListDatasets("*")&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;# within each feature dataset, list the feature classes and write them to the text file&amp;nbsp; &lt;/P&gt;
&lt;P&gt;for dataset in datasetList:&amp;nbsp; &lt;/P&gt;
&lt;P&gt; fcList1 = arcpy.ListFeatureClasses("*","",dataset)&amp;nbsp; &lt;/P&gt;
&lt;P&gt; for fc in fcList1:&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; f.write(fc + "\n")&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;# find all of the feature classes which do not reside within a feature dataset&amp;nbsp; &lt;/P&gt;
&lt;P&gt;fcList2 = arcpy.ListFeatureClasses("*")&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;# write the feature class names to the text file which don't reside in the feature dataset&amp;nbsp; &lt;/P&gt;
&lt;P&gt;for fc in fcList2:&amp;nbsp; &lt;/P&gt;
&lt;P&gt; f.write(fc + "\n") &lt;/P&gt;


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 17:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298878#M23142</guid>
      <dc:creator>EricBay</dc:creator>
      <dc:date>2014-10-08T17:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: ListFeatureClasses python script truncating features</title>
      <link>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298879#M23143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure why that would be truncating the names.&lt;/P&gt;&lt;P&gt;I would do something more simple. Instead of writing to a text file, it just prints the results in the Python interpreter window where you can copy it wherever you want. From my testing in ArcGIS 10.2.2, it successfully prints feature class names longer than 26 characters.&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_141281007500712 jive_text_macro" jivemacro_uid="_141281007500712"&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# specify the geodatabase you want to retrieve feature classes from&lt;/P&gt;
&lt;P&gt;gdb = r"&lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;c:\temp\Tracks.gdb&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# set your environment workspace&lt;/P&gt;
&lt;P&gt;arcpy.env.workspace = gdb&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# List all of the feature datasets and their feature classes&lt;/P&gt;
&lt;P&gt;for ds in arcpy.ListDatasets():&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in arcpy.ListFeatureClasses("","",ds):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "\t", fc&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# List all of the other feature classes outside the feature datasets&lt;/P&gt;
&lt;P&gt;for fc in arcpy.ListFeatureClasses():&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc&lt;/P&gt;







&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;Another solution would be this:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14128132307234338" jivemacro_uid="_14128132307234338" modifiedtitle="true"&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Specify the geodatabase you want to retrieve feature classes from&lt;/P&gt;
&lt;P&gt;gdb = r"&lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;c:\temp\Tracks.gdb&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Set environment workspace&lt;/P&gt;
&lt;P&gt;arcpy.env.workspace = gdb&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Get list of datasets&lt;/P&gt;
&lt;P&gt;datasetList = arcpy.ListDatasets()&lt;/P&gt;
&lt;P&gt;datasetList.append("") ##Add blank list item to catch feature classes not in a dataset&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for ds in datasetList:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in arcpy.ListFeatureClasses("","",ds):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "{}\{}".format(ds, fc)&lt;/P&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 23:14:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298879#M23143</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2014-10-08T23:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: ListFeatureClasses python script truncating features</title>
      <link>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298880#M23144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm also not sure where and why the name should be truncated. However, I would suggest to use arcpy.da.Walk(), simply because you do not have to start over and over again to find all the feature classes within the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14128744583973969 jive_text_macro" jivemacro_uid="_14128744583973969"&gt;
&lt;P&gt;import arcpy, os&lt;/P&gt;
&lt;P&gt;f = open('C:/temp/fc_list.txt', 'a')&lt;/P&gt;
&lt;P&gt;arcpy.env.workspace = r'C:/temp/Tracks.gdb'&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for dirpath, dirnames, filenames in arcpy.da.Walk(arcpy.env.workspace, datatype='FeatureClass'):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_path = os.path.join(dirpath, filename)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(fc_path + '\n')&lt;/P&gt;
&lt;P&gt;f.close()&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't need the complete path skip line 7 and exchange 'fc_path' in line 8 by 'filename'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 17:13:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298880#M23144</guid>
      <dc:creator>TomGeo</dc:creator>
      <dc:date>2014-10-09T17:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: ListFeatureClasses python script truncating features</title>
      <link>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298881#M23145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ID10T error ... Access was the culprit. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 17:46:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listfeatureclasses-python-script-truncating/m-p/298881#M23145</guid>
      <dc:creator>EricBay</dc:creator>
      <dc:date>2014-10-09T17:46:21Z</dc:date>
    </item>
  </channel>
</rss>

