HOW TO

Split the last values in a text field into a new field in ArcGIS Pro

Last Published: October 26, 2022

Summary

In ArcGIS Pro, a text field may contain values separated by delimiters, and it is sometimes necessary to separate the last values into a new field for data analysis. This can be achieved in ArcGIS Pro using the split() method in the Calculate Field function.

The workflow provided in this article involves splitting the last values based on either a delimiter or multiple delimiters, and populating them into a new field using the Calculate Field function. In this example, the Address text field contains values separated by three different delimiters.

The attribute table view of the Address feature layer and the Address text field.

Procedure

  1. In ArcGIS Pro, create a new field to populate the last values.
    1. In the Contents pane, right-click the feature layer or the stand-alone table containing the text values, navigate to Data Design and click Fields.
    2. Follow the workflow described in ArcGIS Pro: Create a field and apply a domain and default value to add a new field to the attribute table. In this example, a new text field named Suffix is created.
The fields view of the Address feature layer and the new Suffix text field.
  1. On the Fields tab, click Save.
  1. In the Contents pane, right-click the feature layer or the stand-alone table containing the text values and click Attribute Table.
  2. In the attribute table view, right-click the header of the new field created in Step 1 and click Calculate Field.
  3. In the Calculate Field window, for Expression Type, ensure Python 3 is selected.
  4. Depending on the number of delimiters, use one of the codes provided below to split the text values.
  • If the text values only contain one delimiter, type the code provided below in the expression box. Replace 'Field Name' with the name of the field containing the text values, and replace <delimiter1> with the delimiter in the text values. In this example, the field name is 'Address' and the delimiter is '*'.
!Field Name!.split("<delimiter1>")[-1]
Note:
Do not remove the exclamation marks surrounding the field name.
The Calculate Field window to be configured.
  • If the text values contain multiple delimiters, type the code provided below in the expression box. The replace() method is used to replace the different delimiters with a single common delimiter. Substitute <old_delimiter_n> with the delimiters to be replaced and substitute <delimiter1> with the common delimiter. In this example, the delimiters to be replaced are '-' and '/', and the common delimiter is '*'.
!Field Name!.replace("<old_delimiter_n>","<delimiter1>").replace("<old_delimiter_n>","<delimiter1>").split("<delimiter1>")[-1]
The expression box in the Calculate Field window.
  1. Click Apply.
  2. Click OK to close the Calculate Field window.

The last values are split based on the delimiters and populated into the new field.

The attribute table view of the Address feature layer and the populated Suffix text field.

Article ID: 000028550

Software:
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 8 x
  • ArcGIS Pro 2 x

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