Hi Pros;
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 :
ART-S-01-00-1050-1-(OFS)
ART-S-01-00-1050-2-(OFS)
ART-S-01-00-1050-3-(OFS)
.
.
.
ART-S-01-00-1050-19-(OFS)
any idea how I can do that in python. considering I am working in an SDE GDB and can't add more fields.
Thanks
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("(")[0] + "-" + 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
Thanks Dan
I assume the C is a new field; right? if yes this will not work as I can't add field as I don't have admin privileges on this GDB.
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("(")[0] ) as it gives double hyphen in the result like ART-S-01-00-1050--1-(OFS)
but anyway, this was helpful, many thanks again