I have two columns in a personal geodatabase table that I'm trying to add up (to a third field) using a python function in field calculator, however some of the string values are not real numbers.
e.g.
field1 field2
12.24 2
h3.3 4
xyz 1
932.33.32 3
I have a conditional statement that checks for letters, however I'm stuck on how to check for the two decimal character occurrence,
932.33.32
For the two decimal string example I just want to return the value of field2. Here is my code so far.
import re
def cal(field1, field2):
#check for two decimal character occurrence
elif re.search('[0-9]+', x):
myvalue = float(field1) + float(field2)
return myvalue
else:
myvaluefinal = float(field1) + float(field2)
return myvaluefinal