Pretty simple question I'm sure for the Python people out there. I have a field, FACILITY ID, that is populated as string values as 00001,00002, 00003, and so on. All values in the field are 5 characters long. I want to change the first number in to a 1 so the values of the field look like 10001, 10002, 10003, etc. I'm pretty sure i should use the .replace(), but I cannot format it correctly. Any advice would be very welcome. Thank you.
Solved! Go to Solution.
"1" + !YourField![1:]
python parser and YourField is the field that contains the original.
It is best to do calculations in a new field in case things go real bad.
You can copy them back into the original later
"1" + !YourField![1:]
python parser and YourField is the field that contains the original.
It is best to do calculations in a new field in case things go real bad.
You can copy them back into the original later
Dan,
Thank you that worked perfect. How would I augment that to change a different value in the string, say the second value to a 5? Again thank you!!!!
Although you asked a follow-up question, Dan addressed your first question. Please mark his response as Correct to close out the question.
"15" + !YourField![2:]
or if you just mean the 2nd value, leaving the first along
!YourField![:1] + "5" +
!YourField![2:]
Thank you Dan!! The second one was exactly what i needed!
no problem