I'm looking for a Python or VB statement to remove the last part of a string, starting where the 1st non Numeric character appears, using the Field Calculator in ArcMap 10. Here's an example of what I'm looking for:

Is it possible?
Answer
Here's a go at it. Use Python as the parser and check show Codeblock.
Enter this in the top Pre-Logic Script Code box:
def getints(field):
integers = []
for char in field:
try:
value = int(char)
integers.append(str(value))
except ValueError:
break
return "".join(integers)
And put this in the bottom box:
getints(!YOURFIELD!)
No comments:
Post a Comment