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 field212.24 2h3.3 4xyz 1932.33.32 3I have a conditional statement that checks for letters, however I'm stuck on how to check for the two decimal character occurrence,
import redef 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
أكثر...
e.g.
field1 field212.24 2h3.3 4xyz 1932.33.32 3I 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 redef 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
أكثر...