HOW TO
In ArcGIS Pro, Python expressions can be used to separate numeric and text fields from a specified text data type field with alphanumeric values. This article provides an example and instructions to create a new numeric and text field by referencing the text field with alphanumeric values using Python expressions.
The attribute table below shows the alphanumeric Name field.

Note: Refer to ArcGIS Pro: Calculate Field (Data Management) for more information on the parameters in the Calculate Field tool.
conv(<textField>)
def conv(<variableName>):
<variableName1> = ''
for chr in <variableName>:
if (ord(chr) >= 48 and ord(chr) <= 57) or ord(chr) == 47 or ord(chr) == 32 or ord(chr) == 45:
<variableName1> = <variableName1> + chr
return <variableName1>
def conv(nameField):
extractNum = ''
for chr in nameField:
if (ord(chr) >= 48 and ord(chr) <= 57) or ord(chr) == 47 or ord(chr) == 32 or ord(chr) == 45:
extractNum = extractNum + chr
return extractNum

Note: To display leading zeroes for the numeric field, refer to How To: Add leading zeroes to numeric fields in ArcGIS Pro for instructions.
conv(<textField>)
def conv(<variableName>):
<variableName1> = ''
for chr in <variableName>:
if not((ord(chr) >= 48 and ord(chr) <= 57) or ord(chr) == 47 or ord(chr) == 32 or ord(chr) == 45):
<variableName1> = <variableName1> + chr
return <variableName1>
def conv(nameField):
extractStr = ''
for chr in nameField:
if not((ord(chr) >= 48 and ord(chr) <= 57) or ord(chr) == 47 or ord(chr) == 32 or ord(chr) == 45):
extractStr = extractStr + chr
return extractStr

The image below shows the new numeric and text fields added to the attribute table.

Article ID: 000031133
Get help from ArcGIS experts
Start chatting now