arcpy.ListFields

3160
5
03-23-2020 11:59 PM
KalSsin
New Contributor III

 Hi~~~

 

I want the following text using the arcpy.

"OBJECTID", "EPOCH", "Shape_Length", "Shape_Area", "NAME", "PNAME"

0 Kudos
5 Replies
JohannesBierer
Occasional Contributor III
0 Kudos
KalSsin
New Contributor III

thank you~~~

This is the data I've already seen.

The table is being sent to Excel to obtain field name from Excel.

0 Kudos
JohannesBierer
Occasional Contributor III

It's not really clear what you want to do? Feature Class to Excel you can use table to excel tool?

0 Kudos
DanPatterson_Retired
MVP Emeritus

The help files have good examples in both arcmap and arcgis pro

ListFields—ArcPy Functions | Documentation 

featureclass = r"c:\path\to_your\data\Geology"
field_names = [f.name for f in arcpy.ListFields(featureclass)]
JoshuaBixby
MVP Esteemed Contributor

Since reading the StackExchange thread didn't appear to help you understand how ListFields works, I will point out directly that ListFields doesn't return a list of field names, it returns a list of field objects.  If you want the names of the fields, you need to add the 2nd line of code in Dan's comment.