HOW TO

Insert special characters between text field values using the Calculate Field tool in ArcGIS Pro

Last Published: May 18, 2023

Summary

In ArcGIS Pro, special characters can be added to the text field values in an attribute table to emphasize, split, or provide distinction to the values of the field. This can be achieved using Python in the Calculate Field window.

Apply the workflow provided to insert characters into an existing field using the Calculate Field tool.

In this article, the special character ',' is added to the field values to improve data readability.

The attribute table fields.

Procedure

Note: 
This calculation can only be applied to text fields because special characters are only supported in the Text data type field.
  1. Open the project in ArcGIS Pro.
  2. In the Contents pane, right-click the layer and click Attribute Table to open the layer's attribute table.
The Attiribute Table option.
  1. In the attribute table view, click the Add Field The Add Field icon. icon to add a field.
    1. In the Fields view, in the Field Name column, specify a name for the new field. In this example, the new field name is 'Sales3'.
    2. Under the Data Type column, double-click the cell to open the drop-down menu and click Text.
    3. On the Fields tab, in the Changes group, click Save. Close the Fields view.
  2. In the attribute table, right-click the newly added field and click Calculate Field. The Sales3 field is used in this example.
The Calculate Field option.
  1. Populate the field with the values from the intended field to add the special character. In the Calculate Field window, configure the parameters.
    1. For Input Table, ensure the layer selected in Step 2 is prefilled. In this example, the input table is Sheet1_XYTableToPoint.
    2. For Field Name (Existing or New), ensure the selected field name is prefilled. Otherwise, select the field from the drop-down menu. In this example, the field name is Sales3.
    3. For Expression Type, select Python 3.
    4. For Expression, in the expression box, type the code provided below. Replace 'Field name' with the name of the field to be cloned. In this example, the Sales2 field is cloned.
!Field name!
  1. Click OK.
The OK button in the Calculate Field window.
  1. In the attribute table, right-click the newly added field and click Calculate Field. The Sales3 field is used in this example.
The Calculate Field option.
  1. Add the special character to the field values. In the Calculate Field window, configure the parameters.
    1. For Input Table, ensure the layer selected in Step 2 is prefilled. In this example, the input table is Sheet1_XYTableToPoint.
    2. For Field Name (Existing or New), ensure the selected field name is prefilled. Otherwise, select the field from the drop-down menu. In this example, the field name is Sales3.
    3. For Expression Type, select Python 3.
    4. For Expression, in the expression box, type the code provided below. Replace 'Field name' with the selected field name in Step 7(b), and 'Insert a special character' with the preferred special character.
!Field name![0:3] + "Insert a special character" + !Field name![3:]
  1. Click OK.
Note: 
The Calculate Field tool permanently modifies inputs by changing values in the attribute fields. To avoid having permanent changes applied, toggle Enable Undo on in the Calculate Field window before running the tool.
The Calculate Field window.
The image below shows the special character ',' is applied to the field.
The attribute table fields.

Article ID: 000030148

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • 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