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 for 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

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Using fields and indexes

When described, feature classes and tables have a fields property that returns a list of field objects, and an indexes property that returns a list of index objects. Each field or index object has a number of properties that can be used to explore the object. Alternatively, the ListFields and ListIndexes functions can be used to create the same lists. The following example shows how to create a field list and loop through the contents to find a specific field.

import arcpy

fc = 'D:/St_Johns/data.gdb/roads'

# Get a list of field objects
#
fields = arcpy.ListFields(fc, 'Flag')

for field in fields:
    # Check the field name, perform a calculation when finding the field 'Flag'
    #
    if field.name == 'Flag':
        # Set the value for the field and exit loop
        #
        arcpy.CalculateField_management(fc, 'Flag', '1')
        break

The properties of the field and index objects are listed below:

PropertyExplanation

name

The name of the field.

aliasName

The alias name of the field.

domain

The name of the associated domain.

editable

True, if the field is editable.

isNullable

True, if the field is nullable.

required

True, if the field is required.

length

The field's length.

type

SmallInteger, Integer, Single, Double, String, Date, OID, Geometry, BLOB.

scale

The field's scale.

precision

The field's precision.

Field properties

PropertyExplanation

name

The name of the index.

isAscending

True, if the index sorts in ascending order.

isUnique

True, if the index is unique.

fields

A list of Field objects. This is the same as using Describe's field property.

Index properties

Tip:

ListFields and ListIndexes can be used to limit the results based on name and type.

Related topics

  • ListFields
  • ListIndexes
  • Create lists of data

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

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