How to remove spaces with Calculate field in ArcCatalog Model

2187
3
12-01-2010 10:43 AM
JoseSanchez
Occasional Contributor III
Hi all

I am trying to remove spaces from a string using model builder in ArcCatalog and I wrote the following in the Calculate Field, field experssion:  !W.TCIS_GIS.PREM_TYPE!.strip()


It shows the following error message:


Executing (Calculate Field): CalculateField PremisePoints_Layer PremisePoints.PREMTYPE " !WASD.TCIS_GIS.PREM_TYPE!.strip() " PYTHON # PremisePoints_Layer
Start Time: Wed Dec 01 15:37:55 2010
ERROR 000539: Error running expression:  "TWNHOUSE".strip()  <type 'exceptions.IndentationError'>: unexpected indent (<string>, line 1)
Item not found in this collection.
Failed to execute (Calculate Field).
End Time: Wed Dec 01 15:38:00 2010 (Elapsed Time: 5.00 seconds)
Tags (2)
0 Kudos
3 Replies
NolanGeise
New Contributor
If I'm using the Calculate Field function to replace things I normally just use

Replace([Field_Name], "remove item", "replace item")

seems to work well for me.
0 Kudos
JoseSanchez
Occasional Contributor III
Do you enter that in model builder?

What  about fields from SDE with fully qualified names  [owner].[feature class].[field]  how do you use the replace in this case?
0 Kudos
NolanGeise
New Contributor
I would just input a generic string like Replace([Field_Name], "Out", "In") in the tool within ModelBuilder and then set the expression as a model parameter as well as the input table and field, that way you have the flexibility of changing your inputs when you run the model. If it is the exact same expression (field name and all) every time you could just enter the correct expression into the tool in ModelBuilder and not set it as a model parameter.

The other stuff you're talking about is not something I would not be comfortable answering. I would think that as long as the field names are the same in the expression as they are in the table it should work but that kind of logic doesn't alway pan out with Arc, at least not for me.
0 Kudos