<?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: Print fields indexes of featur class in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/print-fields-indexes-of-featur-class/m-p/1281078#M67469</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

#arcpy map read current project # can also pass the full path
aprx = arcpy.mp.ArcGISProject("CURRENT")

# List of FeatureClasses in Geodatabase
featureclasses = arcpy.ListFeatureClasses()

# the feature class that you want to check
featureclass_name = 'featureclass of interest'

# list of field (column) objects in the Attribute Table of the Feature Class
fields_ls = arcpy.ListFields(featureclass_name)  # object 
fields_names_ls= [f.name for f in fields_ls]  # name

for c,i in enumerate(fields_names_ls):
    print(f'{c:02}-{i}') # zero padded the index to match visually&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was a general example using Python. I zero padded the index to match them visually in case of having more than 10 fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can replace the last line by the following if that is not what you want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt; print(f'{c} {i}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List of feature classes was included just in case you need that, otherwise you can skip that line.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2023 22:29:01 GMT</pubDate>
    <dc:creator>Mahdi_Ch</dc:creator>
    <dc:date>2023-04-20T22:29:01Z</dc:date>
    <item>
      <title>Print fields indexes of featur class</title>
      <link>https://community.esri.com/t5/python-questions/print-fields-indexes-of-featur-class/m-p/1281014#M67467</link>
      <description>&lt;P&gt;How can you print out the field index and fields name of all the fields in a feature class?&lt;/P&gt;&lt;P&gt;print out something like this,&lt;/P&gt;&lt;P&gt;0 OBJECTID&lt;BR /&gt;1 Shape&lt;BR /&gt;2 GlobalID&lt;BR /&gt;3 field1&lt;BR /&gt;4 field2&lt;BR /&gt;5 field3&lt;BR /&gt;6 field4&lt;BR /&gt;7 field5&lt;BR /&gt;etc...&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 20:32:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-fields-indexes-of-featur-class/m-p/1281014#M67467</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2023-04-20T20:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Print fields indexes of featur class</title>
      <link>https://community.esri.com/t5/python-questions/print-fields-indexes-of-featur-class/m-p/1281078#M67469</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

#arcpy map read current project # can also pass the full path
aprx = arcpy.mp.ArcGISProject("CURRENT")

# List of FeatureClasses in Geodatabase
featureclasses = arcpy.ListFeatureClasses()

# the feature class that you want to check
featureclass_name = 'featureclass of interest'

# list of field (column) objects in the Attribute Table of the Feature Class
fields_ls = arcpy.ListFields(featureclass_name)  # object 
fields_names_ls= [f.name for f in fields_ls]  # name

for c,i in enumerate(fields_names_ls):
    print(f'{c:02}-{i}') # zero padded the index to match visually&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was a general example using Python. I zero padded the index to match them visually in case of having more than 10 fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can replace the last line by the following if that is not what you want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt; print(f'{c} {i}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List of feature classes was included just in case you need that, otherwise you can skip that line.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 22:29:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-fields-indexes-of-featur-class/m-p/1281078#M67469</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-04-20T22:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Print fields indexes of featur class</title>
      <link>https://community.esri.com/t5/python-questions/print-fields-indexes-of-featur-class/m-p/1281081#M67470</link>
      <description>&lt;P&gt;I'm not sure if you're talking about an automated way to do this, but for a quick solution, I usually just right-click the layer / Data Design / Fields. Then click the upper left of that table (with the small triangle) to select everything, then right-click again to copy, then just paste it into Excel. You'll have to add your own "field index" - I don't know of any view in ArcGIS that gives a field "index"&lt;/P&gt;&lt;P&gt;In a python window you could do something this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;i=0
for f in arcpy.ListFields(feature_class):
    print(str(i) + " " + f.name)
    i+=1&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Apr 2023 22:26:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-fields-indexes-of-featur-class/m-p/1281081#M67470</guid>
      <dc:creator>ChrisRingo</dc:creator>
      <dc:date>2023-04-20T22:26:47Z</dc:date>
    </item>
  </channel>
</rss>

