Hello, I am hoping somebody is able to help me.
I manage several point feature classes that relate to heritage sites in NSW. Each of these sites is also attributed a state identifying number as they are registered with the government. I am hoping to simplify the editing process by running a field calculation.
The feature class contains a UNIQUE_ID (type: double) attribute, as well as a LEASE (Type: string) attribute, and these two values together comprise the same information reflected in the third attribute, called SITE_NAME, which represents the state registered site name. For example:
UNIQUE_ID: 100
LEASE: MTP
SITE_NAME: MTP-100
I would have thought it'd be simple to generate a field calculator for SITE_NAME by combining UNIQUE_ID and LEASE:
SITE_NAME =
[LEASE] + [UNIQUE_ID]
and this would eliminate the need to generate code to add numbers on to each entry etc., as the site name number directly reflects the UNIQUE_ID.
However I have run multiple calculations with different inputs and each time it fails. Can anybody suggest what I am doing wrong? I am absolutely terrible at using Python so I was hoping I could use VBScript for this, but I'll take what I can get.
TIA,
Jess
Solved! Go to Solution.
you'll need to cast the unique id to a string
!LEASE! + "-" + str(!UNIQUE_ID!)
Python parser... no code block
!LEASE! + "-" + !UNIQUE_ID!
Obviously, has to go in a text field of an appropriate length
Make that field active, and ensure that the fields are exactly as they appear in the table.
The wise person, doesn't type in the field names, but selects them from the list of fields. If the correct python parser is chosen, the the ! marks will appear around the field. The + is used to concatenate elements together.
Hi Dan, thank you for replying.
This was a process that I attempted earlier, to no avail unfortunately. I simply get the message, "There was a failure during processing, check the Geoprocessing Results window for details". I have attached the results in case that helps. It would appear that it is having an issue with trying to concatenate a string and a number attribute? at least, this is what Error 000539 means.
.
you'll need to cast the unique id to a string
!LEASE! + "-" + str(!UNIQUE_ID!)
Thank you Wes! that worked! Although it gave the SITE_NAME decimal points, i.e. MTP-100.0, MTP-101.0. Is there any way to prevent it displaying as decimal points?
Otherwise, I am very happy- thank you so much!
Try this
!LEASE! + "-" + str(int(!UNIQUE_ID!))
Champion- that worked perfectly.
Thank you all so much, you have really helped me out!!