HOW TO

Remove leading zeros in an attribute table in ArcGIS Pro

Last Published: July 4, 2024

Summary

Removing leading zeros from a field in an attribute table can be time-consuming if the data provided is large, as shown in the image below. However, this task can be automated using a Python or Arcade expression. In Python, the Int() function is used to remove the leading zeros from a text data type field; deeming the values as integers, thus preventing the population of numbers beginning with a zero ('0'). This article provides the workflow to automate the removal of leading zeros from a field in an attribute table using a Python or Arcade expression in ArcGIS Pro.

The data with leading zeros under the Distance field in an attribute table.

Procedure

  1. Open the ArcGIS Pro project.
  2. In the Contents pane, right-click the layer and click Attribute Table.
  3. In the attribute table, right-click the field’s header and select Calculate Field.
  4. In the Calculate Field window, select the field from the Field Name (Existing or New) drop-down list. In this example, Distance (KM) is selected.
  5. Select Python 3 or Arcade from the Expression Type drop-down list.
The parameters in the Calculate Field window.
  • For Python 3, in the <Field_Name> box, type the following expression and click Verify.
Int(!<Field_Name>!)
The Python expression configured in the expression box.
  • For Arcade, in the <Field_Name> box, type the following expression and click Verify.
Number($feature.<Field_Name>)
The Arcade expression configured in the expression box.
  1. When the message, "Expression is valid" is returned, click OK.
The Expression is valid message is returned.

The following image shows the leading zeros removed from the data in the attribute table.

The leading zeros removed from the data in the attribute table.

Article ID: 000030731

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 9x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options