# WHAT I HAVE PROBLEM WITH THIS EXPRESSION

166
6
01-11-2020 11:38 AM
Highlighted
New Contributor III

I NEED PUT THE COORDINATE AND THE WORD : NOMBRE, LIKE: 57485.258 NOMBRE

1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

POINT_X and POINT_Y are both numeric type fields.  You will need to add two new fields of String type in order to concatenate the word NOMBRE to it.

Add two new string type field, naming them as you wish.

Then in the field calculator you can copy and paste the following for each of the new fields:

``str(!POINT_X!)+' '+'NOMBRE'str(!POINT_Y!)+' '+'NOMBRE'‍‍‍``

This casts the value of each variable to a string and then puts a space between the value and NOMBRE.  You may need to set the format of the POINT_X and POINT_Y fields to the number of decimal places you want to display.

6 Replies
Highlighted
MVP Esteemed Contributor

POINT_X and POINT_Y are both numeric type fields.  You will need to add two new fields of String type in order to concatenate the word NOMBRE to it.

Add two new string type field, naming them as you wish.

Then in the field calculator you can copy and paste the following for each of the new fields:

``str(!POINT_X!)+' '+'NOMBRE'str(!POINT_Y!)+' '+'NOMBRE'‍‍‍``

This casts the value of each variable to a string and then puts a space between the value and NOMBRE.  You may need to set the format of the POINT_X and POINT_Y fields to the number of decimal places you want to display.

Highlighted
New Contributor III

thanks for your fast and effective answer

Highlighted
MVP Esteemed Contributor

To avoid whether you need cast things to strings, learn the python "format" mini-language.  It can all be done on 1 line and is even more powerful than its sibling the f-string.

"{}

`` "{} {}".format('a string', 1)  # ---- implicit order'a string 1'"{1} {0}".format('a string', 1) # ---- explicit order '1 a string'"{}{}{}".format('stuff', " in between "*3, ['a, b', 1, 2.0])  # ---- it can do anything"stuff in between  in between  in between ['a, b', 1, 2.0]"‍‍‍‍‍‍‍‍``
Highlighted
New Contributor III

Very good, it´s working. Thanks

Highlighted
MVP Esteemed Contributor

Armando Freites‌, please mark one of the responses as Correct to close out your question.  If multiple people gave you good answers, pick the one that helped the most and mark it correct while marking the others as helpful.

Highlighted
New Contributor III

Ok ok