I refer to Extracting numbers from string field using Python Parser of ArcMap Field Calculator?
The script above works fine for me, but I have to develop it a little. What I want is just to omit values without numbers. As you see in the table TEXTSTRING field with ID = 10 got only letters, it's Ok if Python leaves it empty, I just want make it go through all values in table.
target column is test_srednica2
Below you see my attempt :/
def makestr(TEXTSTRING):
lis = []
for i in TEXTSTRING:
if i.isdigit():
lis.append(i)
elif i.isalpha():
continue
return ''.join(lis)
Below i put code which has filled field "test_srednica2" As you see in table it is working until row "13" there is value "woc". There is no number so i think that`s why this function stops.
I want my function leave cells with letters only, and go throught all the others.
If you look on row "11" you see its going throught even if value is "<Null>" it
s OK for me.
def makestr(TEXTSTRING):
lis = []
for i in TEXTSTRING:
if i.isdigit():
lis.append(i)
return ''.join(lis)