ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

ListFields

  • Summary
  • Syntax
  • Code sample

Summary

Returns a list of fields in a feature class, shapefile, or table in a specified dataset. The returned list can be limited with search criteria for name and field type and will contain field objects.

Syntax

ListFields (dataset, {wild_card}, {field_type})
ParameterExplanationData Type
dataset

The specified feature class or table with the fields to be returned.

String
wild_card

Limits the results returned. If a value is not specified, all values are returned. The wildcard is not case sensitive.

SymbolDescriptionExample

*

Represents zero or more characters.

Te* finds Tennessee and Texas.

(The default value is None)

String
field_type

The specified field type to be returned. The following are valid field types::

  • All — All field types are returned. This is the default.
  • BLOB —Only field types of BLOB are returned.
  • Date —Only field types of Date are returned.
  • Double —Only field types of Double are returned.
  • Geometry —Only field types of Geometry are returned.
  • GlobalID —Only field types of GlobalID are returned.
  • GUID —Only field types of GUID are returned.
  • Integer —Only field types of Integer are returned.
  • OID —Only field types of OID are returned.
  • Raster —Only field types of Raster are returned.
  • Single —Only field types of Single are returned.
  • SmallInteger —Only field types of SmallInteger are returned.
  • String —Only field types of String are returned.

(The default value is All)

String

Return Value

Data TypeExplanation
Field

A list containing Field objects is returned.

Code sample

ListFields example

List field properties.

import arcpy

# For each field in the Hospitals feature class, print
#  the field name, type, and length.
fields = arcpy.ListFields("c:/data/municipal.gdb/hospitals")

for field in fields:
    print("{0} is a type of {1} with a length of {2}"
          .format(field.name, field.type, field.length))
ListFields example 2

Generate a list of field names.

import arcpy

featureclass = "c:/data/municipal.gdb/hospitals"
field_names = [f.name for f in arcpy.ListFields(featureclass)]

Related topics

  • Create lists of data
  • Using fields and indexes
  • Field

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal