But I didn't think it was possible to use python with Arc 9.3.1....is it?
Mid([Row_Col],1,InStr([Row_Col],"-")-1)
I want to extract the columns and rows into their own fields such that "23-999" becomes "23" and "999" using "-" as a delimiter. The problem is that the lengths are variable, eg the field can contain values like "1-2", "351-7", "81-253" which makes substring, trim, left and right commands tricky.
!Col_Row!.split("-")[0] !Col_Row!.split("-")[1]
Try something like this in the field calculator.Expression:ReplaceLastNumber(!textfield!, !numberfield!) Code block:import re def ReplaceLastNumber(text_value, number_value): numbers = re.findall("\d+", text_value) if numbers: last_number = numbers[-1] last_number_index = text_value.rfind(last_number) return text_value[:last_number_index] + str(number_value) + text_value[last_number_index + len(last_number):] else: return text_value
ReplaceLastNumber(!textfield!, !numberfield!)
import re def ReplaceLastNumber(text_value, number_value): numbers = re.findall("\d+", text_value) if numbers: last_number = numbers[-1] last_number_index = text_value.rfind(last_number) return text_value[:last_number_index] + str(number_value) + text_value[last_number_index + len(last_number):] else: return text_value
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.