My values are padded with spaces. Sometimes it's "1", sometimes it's " 1" sometimes its "1 ".
I need to remove all the spaces before, between, after, wherever they appear...
Thanks!!!!
For leading and trailing whitespace, I would recommend using Python String strip() Method
Here's an example:
For any and all spaces, try replace:
Thanks, Chris. I need to use it in the Model. I am not familiar how I can add this to the model... Is there any way to do it with Field Calculator?
Sure, here's an example in the model (for replace):
This tool is available under...
>> Data Management Tools
>> Fields
>> Calculate Field
Chris, it works but I get zeros for some of the values..
For example, before I had "B", " B", "000B2"
After calculation I get: "B", "000B", "000B2"
I don't want it to be "000B"
For the rest of the records it worked fine
So you want to remove whitespace AND zeros? If you'd like to remove zeros as well, is it just leading zeros?
Chris... I would wait until you get a list of all possible iterations, permutations and combinations that could be in the table. This sounds like a test of the most horrible kind... working in modelbuilder...with an ever increasing list of new conditions.
I was thinking along those lines since it sounds like scope is creeping a bit...
Liana,
Just a warning, too - make sure you have a back-up of your data before running processes that are final!
I want to remove just the spaces. Some of the values should have zeros before them. The problem is that after calculation for the case " B" (three spaces before letter) I get "000B". It should become B, not 000B
I see now... that's strange - can you give your processes step-by-step? Are you positive "000B" wasn't the value before the strip/replace was executed? Could you possibly supply a file, without any identifiable info, exemplifying the issue?