HOW TO
In ArcGIS Pro, Python can be used to extract and sum numeric values from a text field containing alphanumeric data. This is useful when numeric information embedded in text strings is extracted for calculations, such as summing quantities, unit numbers, or identification values.
This article provides the workflow to extract and sum numbers from a text field using Python in ArcGIS Pro.
extract_sum(!<fieldName>!)
import re
def extract_sum(value):
if value:
return sum([int(x) for x in re.findall(r'\d+', value)])
return 0

The attribute table below shows the sum of numbers extracted from the text field for each record.

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