Tuesday, April 19, 2011

ArcGIS python script to print the field names of a feature or shp file

Open the command windows in your arcgis and run the following scrip. Dont forget to edit TypeYourFeature with your feature.


featurename='TypeYourFeature'
for field in arcpy.ListFields(featurename):
print field.name


Example:
If you have shp file named "streets.shp" located in D:/Mycity/roads then you need to write

featurename='D:/Mycity/roads/streets.shp'
for field in arcpy.ListFields(featurename):
print field.name

Please leave your comment if you find any error.

No comments:

Post a Comment