I have this table
and need to take the numbers after hyphen in CAD_DESIGN_ROOMID field and put it before the last three letters in ROOMCODE field with another hyphen. I need the result to look like this :
any idea how I can do that in python. considering I am working in an SDE GDB and can't add more fields.
with a code block and you replacing 'a' and 'b' with their appropriate fieldnames in double ! marks
a = "ART-S-01-00-1050(OFS)" b = "1050A-1" c = a.split("(") + "-" + b.split("-")[-1] + "-(" + a.split("(")[-1] c 'ART-S-01-00-1050-1-(OFS)' # ---- a = !a_field! b = !b_field!
But you had better have an undo or check your results before committing the results.... otherwise, its on you
c is a ... it would be best if it went into a new field, but if you have to overwrite 'a' then you would do the field calculation on it. A practice I am not recommending (except on a backup copy of the table)
Thanks a million Dan;
I think we have to remove the + "-" after the first part ( a.split("(") ) as it gives double hyphen in the result like ART-S-01-00-1050--1-(OFS)
but anyway, this was helpful, many thanks again