Geographic Information Systems Asked by Jan Novák on July 8, 2021
I’m trying to get a part of a string (numbers after letter) in a new table (field Description) using field calculator, but I need it only from a field next to it (field MUID) containing the first letter "P" while the rest, that contains something else will be null.
That means if MUID = P14 then Desc = 14 or MUID = P1 then Desc = 1 and if MUID = HT9 then Desc = 0.
Is there a way to write it in the Python parser?
Will need it in the future to implement it via ModelBuilder.
I tried to use this, but it keeps getting Error signs
Try this using python parser:
def nums(textfield):
if textfield[0]=='P': #If first letter is P
newval = ''.join([n for n in textfield if n.isnumeric()]) #List all numbers and join them together to a string
try: #If there is no integer this will prevent the code from breaking
int(newval)
return newval
except ValueError: #Dont return / return NULL if there is no number
pass
Correct answer by BERA on July 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP