<?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: Py.Problem in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264247#M20355</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan is correct about the indentation issue when looping through the field names. You want to output each field name for each feature class so you need to nest the fields loop within the feature class loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This partial example adds all of the field names to a python list and then outputs the feature class name followed by the fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fcName = fcList
if not fcName:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\tNone\n'
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcName:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldNames = arcpy.ListFields(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList = []
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fieldNames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList.append(str((" {0} ({1})".format(field.name, field.type))))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(fc) + ": " + ', '.join(fieldList)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;FeatureClasses:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Richmond:&amp;nbsp; OBJECTID (OID),&amp;nbsp; RIVER_BASIN_NAME (String),&amp;nbsp; SHAPE (Geometry),&amp;nbsp; SHAPE_Length (Double),&amp;nbsp; SHAPE_Area (Double)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Richmond_Strahler:&amp;nbsp; OBJECTID (OID),&amp;nbsp; SHAPE (Geometry),&amp;nbsp; TOPOID (Integer),&amp;nbsp; CLASSSUBTYPE (Integer),&amp;nbsp; HYDRONAME (String),&amp;nbsp; HYDRONAMETYPE (String),&amp;nbsp; PERENNIALITY (SmallInteger),&amp;nbsp; HIERARCHY (SmallInteger),&amp;nbsp; HYDROTYPE (SmallInteger),&amp;nbsp; CMA (String),&amp;nbsp; COMMENTS (String),&amp;nbsp; SUBCMA (String),&amp;nbsp; STRAHLER (SmallInteger),&amp;nbsp; SHAPE_Length (Double),&amp;nbsp; SomeDate (Date)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:56:47 GMT</pubDate>
    <dc:creator>OwenEarley</dc:creator>
    <dc:date>2021-12-11T12:56:47Z</dc:date>
    <item>
      <title>Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264241#M20349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to write a code that will loop through a gdb listing all tables, rasters and featureclasses. It must also list all fields and their types in the featureclasses and print them. I can get everything to print properly with the exception of the ListField. Once I started playing with that command it went down hill. I think the problem lies in determining the dataset for the ListField to run through, I do not know how to tell the ListField to target every featureclass in the designated gdb.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;### Set Workspace&lt;/P&gt;&lt;P&gt;##gdbpath = raw_input ('Enter File Full Pathname to Geodatabase')&lt;/P&gt;&lt;P&gt;##if arcpy.Exists(gdbpath):&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'GDB Found'&lt;/P&gt;&lt;P&gt;##else:&lt;/P&gt;&lt;P&gt;##&amp;nbsp;&amp;nbsp;&amp;nbsp; exit('Invalid Pathname')&lt;/P&gt;&lt;P&gt;gdbpath = 'C:\Users\Stanton\Documents\GISProgramming\Database\Database\Corvallis.gdb'&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = gdbpath&lt;/P&gt;&lt;P&gt;basepath = os.path.basename(gdbpath)&lt;/P&gt;&lt;P&gt;dirpath = os.path.dirname(gdbpath)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print '='*60&lt;/P&gt;&lt;P&gt;print '='*60&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# GDB Name&lt;/P&gt;&lt;P&gt;print 'File Geodatabase Name: ' + basepath&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#GDB Directory&lt;/P&gt;&lt;P&gt;print 'File Geodatabase Directory: ' + dirpath&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Number of Feature Classes&lt;/P&gt;&lt;P&gt;fcList = arcpy.ListFeatureClasses()&lt;/P&gt;&lt;P&gt;numberFC = len(fcList)&lt;/P&gt;&lt;P&gt;print 'Number of FeatureClasses: ' + str(numberFC)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Number of Tables&lt;/P&gt;&lt;P&gt;tableList = arcpy.ListTables()&lt;/P&gt;&lt;P&gt;numberTables = len(tableList)&lt;/P&gt;&lt;P&gt;print 'Number of Tables: ' + str(numberTables)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Number of Rasters:&lt;/P&gt;&lt;P&gt;rasterList = arcpy.ListRasters()&lt;/P&gt;&lt;P&gt;numberRasters = len (rasterList)&lt;/P&gt;&lt;P&gt;print 'Number of Rasters: ' + str(numberRasters)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print '='*60&lt;/P&gt;&lt;P&gt;print '='*60&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Table Names&lt;/P&gt;&lt;P&gt;tableName = tableList&lt;/P&gt;&lt;P&gt;if not tableName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Tables:'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\tNone\n'&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Tables:'&lt;/P&gt;&lt;P&gt;for fc in tableName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\t' + fc + '\n'&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Raster Names&lt;/P&gt;&lt;P&gt;rasterName = rasterList&lt;/P&gt;&lt;P&gt;if not rasterName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Rasters:'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\tNone\n'&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Rasters:'&lt;/P&gt;&lt;P&gt;for fc in rasterName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\t' + fc + '\n'&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#FeaturClassNames and Field Names&lt;/P&gt;&lt;P&gt;fcName = fcList&lt;/P&gt;&lt;P&gt;if not fcName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\tNone\n'&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'&lt;/P&gt;&lt;P&gt;dataset = gdbpath&lt;/P&gt;&lt;P&gt;fieldName = arcpy.ListFields(dataset,'*','All')&lt;/P&gt;&lt;P&gt;for fc in fcList:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\t' + fc + fieldName&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 19:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264241#M20349</guid>
      <dc:creator>Stanton_Coman</dc:creator>
      <dc:date>2015-02-14T19:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264242#M20350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to use list fields on each featureclass not on a path as you currently have it. It should be inside your last loop.&amp;nbsp; check the syntax in the list fields topic&amp;nbsp; &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/ListFields/03q30000001t000000/" title="http://resources.arcgis.com/en/help/main/10.2/index.html#/ListFields/03q30000001t000000/"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 20:21:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264242#M20350</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-14T20:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264243#M20351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply. I understand that much but what I don't understand is how such a code would be written. I have little to no coding experience. How would I construct a code that would use the listfields on each individual featureclass in any designated gdb? Below is what I have written now with no success still.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#FeaturClassNames and Field Names&lt;/P&gt;&lt;P&gt;fcName = fcList&lt;/P&gt;&lt;P&gt;dataset = fc in gdbpath&lt;/P&gt;&lt;P&gt;fieldName = arcpy.ListFields(dataset,'*','ALL')&lt;/P&gt;&lt;P&gt;for field in fieldName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList = ("{0} ({1})".format(field.name, field.type))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not fcName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\tNone\n'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'&lt;/P&gt;&lt;P&gt;for fc in fcList:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\t' + fc + fieldList&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 20:52:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264243#M20351</guid>
      <dc:creator>Stanton_Coman</dc:creator>
      <dc:date>2015-02-14T20:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264244#M20352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is still the same...you have to get a cycle through the featureclasses in the geodatabase, then for each featureclass, get a list of its fields, then for each field ... do something, like get its name etc.... in pseudocode since I don't have arcmap on this machine&lt;/P&gt;&lt;P&gt;featureclass_list....get a list of the feature classes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for each featureclass in featureclass_list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list_fields in featureclass&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for each field in list_fields&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...do something&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 20:59:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264244#M20352</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-14T20:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264245#M20353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan, that helped with my understanding of the problem. Still having trouble with the output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#FeaturClassNames and Field Names&lt;/P&gt;&lt;P&gt;fcName = fcList&lt;/P&gt;&lt;P&gt;if not fcName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\tNone\n'&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldName = arcpy.ListFields(fc)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fieldName:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\t' + str(fcName) + str((" {0} ({1})".format(field.name, field.type)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the result is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FeatureClasses:&lt;/P&gt;&lt;P&gt;&amp;nbsp; [u'Address', u'Building', u'BoundaryLine', u'BoundaryPoly', u'Hydrant', u'Manhole', u'MapGrid', u'Parcel', u'ParkingMeters', u'Parks', u'Railroad', u'River', u'Schools', u'Sewer', u'StLights', u'WaterMeter', u'StPaved', u'Hydrant_buff', u'poop_buff', u'poop2_buff'] OBJECTID (OID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on for each type of field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 21:35:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264245#M20353</guid>
      <dc:creator>Stanton_Coman</dc:creator>
      <dc:date>2015-02-14T21:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264246#M20354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;still no an ArcMap...but your last 2 lines need to be indented so that it will cycle through the fieldnames&lt;/P&gt;&lt;P&gt;for fc in fcNamd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; fieldName...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; for field in&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Feb 2015 22:04:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264246#M20354</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-14T22:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264247#M20355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan is correct about the indentation issue when looping through the field names. You want to output each field name for each feature class so you need to nest the fields loop within the feature class loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This partial example adds all of the field names to a python list and then outputs the feature class name followed by the fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fcName = fcList
if not fcName:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\tNone\n'
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'FeatureClasses:'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcName:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldNames = arcpy.ListFields(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList = []
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fieldNames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList.append(str((" {0} ({1})".format(field.name, field.type))))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(fc) + ": " + ', '.join(fieldList)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;FeatureClasses:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Richmond:&amp;nbsp; OBJECTID (OID),&amp;nbsp; RIVER_BASIN_NAME (String),&amp;nbsp; SHAPE (Geometry),&amp;nbsp; SHAPE_Length (Double),&amp;nbsp; SHAPE_Area (Double)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Richmond_Strahler:&amp;nbsp; OBJECTID (OID),&amp;nbsp; SHAPE (Geometry),&amp;nbsp; TOPOID (Integer),&amp;nbsp; CLASSSUBTYPE (Integer),&amp;nbsp; HYDRONAME (String),&amp;nbsp; HYDRONAMETYPE (String),&amp;nbsp; PERENNIALITY (SmallInteger),&amp;nbsp; HIERARCHY (SmallInteger),&amp;nbsp; HYDROTYPE (SmallInteger),&amp;nbsp; CMA (String),&amp;nbsp; COMMENTS (String),&amp;nbsp; SUBCMA (String),&amp;nbsp; STRAHLER (SmallInteger),&amp;nbsp; SHAPE_Length (Double),&amp;nbsp; SomeDate (Date)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:56:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264247#M20355</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2021-12-11T12:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Py.Problem</title>
      <link>https://community.esri.com/t5/python-questions/py-problem/m-p/264248#M20356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan and Owen thanks for the help! &lt;/P&gt;&lt;P&gt;The indentation made it run and from there I just had to play with the print statement to get it in the right format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 00:24:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/py-problem/m-p/264248#M20356</guid>
      <dc:creator>Stanton_Coman</dc:creator>
      <dc:date>2015-03-06T00:24:36Z</dc:date>
    </item>
  </channel>
</rss>

