Last active
August 29, 2015 14:19
-
-
Save NPS-ARCN-CAKN/c7c91e060665e1c1e5b2 to your computer and use it in GitHub Desktop.
Python: Loop through a FeatureClass' column names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
fc = "C:/Work/VitalSigns/ARCN-CAKN Dall Sheep/Data/LegacySurveyUnits/ARCN_Subunits_Sheep_WGS84.shp" | |
fieldsList = arcpy.ListFields(fc) #get the fields | |
fields = [] # create an empty list | |
# loop through the fields and add the columns to the list, change the Shape column (containing geometry) into a token, | |
for field in fieldsList: | |
if field.name == "Shape": | |
fields.append("Shape@") | |
else: | |
fields.append(field.name) | |
# loop through the fields and output them | |
i = 0 | |
for field in fieldsList: | |
print field.name + " = row[" + str(i) + "]" | |
i = i + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment