Am interested in combining ClASS1 and SUBCLASS1 to form the one combined class. I wrote the expression as follows "() ()" format( !CLASS1!replace(" "","" ),( !SUBCLASS1!replace(" "","" ))as shown in the Image[![field to be combined and expression] [![enter image description here] enter image description here
but after executing I get the following error message error message
-
1Please always present errors as text rather than pictures.PolyGeo– PolyGeo ♦2017年06月30日 21:44:01 +00:00Commented Jun 30, 2017 at 21:44
2 Answers 2
If spaces before or after the values in CLASS1
and SUBCLASS1
are the only issue, the expression could be simplified by using the strip
method instead:
"{} {}".format(!CLASS1!.strip(), !SUBCLASS1!.strip())
As the error states, your syntax is wrong. I assume you want to replace spaces with commas. Try this line for your expression:
"{} {}".format(!CLASS1!.replace(" ",","),(!SUBCLASS1!.replace(" ",","))
EDIT:
Since I now see what your data looks like, I guess the .strip()
option is the nicer choice. If you still want to use the .replace()
function try this:
"{} {}".format(!CLASS1!.replace(" ",""),(!SUBCLASS1!.replace(" ",""))
-
Should 0 and 1 be in between the curly brackets? like this: "{0}{1}"... will still work if the curly brackets are empty?Delonix R.– Delonix R.2017年06月30日 14:55:04 +00:00Commented Jun 30, 2017 at 14:55
-
the {0} and {1} are only necessary, if you refer to the place markes in a different order. example: "{0} {1} {0}".format("A", "B") will return "A B A". so in this case they are not necessary.dru87– dru872017年06月30日 14:57:22 +00:00Commented Jun 30, 2017 at 14:57
-
@DelonixR. if no indices are used in the expression,
format
will use the parameters in the order they are entered.Bjorn– Bjorn2017年06月30日 14:57:52 +00:00Commented Jun 30, 2017 at 14:57
Explore related questions
See similar questions with these tags.