2

I currently use a script that converts the integer in OBJECTID to a string and combines it with another string (in this case UAW,) to populate a field

Field = str(!OBJECTID!) + "UAW"

Now that I have populated my fields how can I modify my script so only empty fields are changed moving forward?

I am using the Python Parser in Calculate Field of ArcGIS Pro.

2

Empty fields read as None-- set your new value if the current value is None, otherwise set it to the current value.

Field = str(!OBJECTID!) + "UAW" if !Field! is None else !Field!
  • Mike thank you for the response, but I am getting a syntax error when I copy over to code block in ArcPro. It is flagging the space after the last exclamation point as Invalid Syntax. – SalasJ Mar 5 at 19:48
  • I don't have access to Pro, but you shouldn't need to use the "pre-logic" code block at all since that's a single liner. it works fine using the main expression box in 10.3, at least – mikewatt Mar 5 at 20:11

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.