0

I'm attempting to Field Calculate the GlobalID field into a text-equivalent version of it, named GlobalID_T. This new text field will have the exact values for records calculated into it, except for the curly brackets at the beginning and end of the number string. All values the same for all records except the curly brackets. How can I accomplish this?

  • Welcome to GIS SE! As a new user please take the tour to learn about our focused Question and Answer format. What have you tried? Please edit your question to include info about any attempts you've made and where you're stuck. – Midavalo Feb 8 '17 at 17:23
4

In field calculator for field GlobalID_T switch to the Python Parser and enter

!GlobalID![1:-1]

This will take the value in the GlobalID field and remove the first and last character (your curly brackets).

enter image description here

Result in the attribute table:

enter image description here

  • I wanted to better understand how this scripting works, so I typed the following: !GlobalID![1] clicked OK... and !GlobalID![-1] clicked OK I noticed that in the first example, the first character inside the first curly bracket was returned. However, in the second example, the last curly bracket itself was returned. This does not seem consistent, could you explain this one a little more? – Michael Feb 8 '17 at 20:06
  • @Michael Look into string slicing in Python. See An Informal Introduction to Python - Strings. While playing with these values, trying using !GlobalID![1:] and !GlobalID![:-1], and also trying changing the numbers to see the different results - !GlobalID![5], !GlobalID![2:-5] etc. – Midavalo Feb 8 '17 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.