I'm trying to remove "." from various string of different length and would be great if anyone could advise or correct me on the right VB code.
Example of the data that I am using are as follows;
Some of the string above have a "." at the back while others don't and they are all of different Length. The code I've written below simply take away the last character regardless if they are "." or not. Would be great if anyone could help me with this.
rTrim( Left ([MACodeLongDescription], LEN([MACodeLongDescription]) -1))
Thank y'all in advance.
Set the python parser in the field calculator. VB is no longer supported, so begin to learn Python and Arcade
# ---- examples
a = 'Apple.'
a = 'Pear'
Now for your field calculation you simply need to include the fieldname in ! ie !OriginalData! and calculate values preferably in a new text field ... like
!OldField!.replace(".", "") # ---- no spaces between the double quotes
Why aren't you using the field calculator? (right-click on the field you want to calculate values for and follow on)
In any event
Field name is the field you are calculating into.
The field name used in the expression is the one that contains the old data and it should be different than the field name
I'm actually doing this in the model building environment..taking the input field, removing the trailing "." if any and replacing the new values into the original field
Apologies for any confusion caused. Just started exploring ArcGis.
Bryan ... switch the parser to python and set it to string. It isn't a good idea to replace an existing field, add a new field prior to this step and use it to house the results.
Just FYI, another way to remove the right most string in VB is to use the String Reverse method, remove first string using left or mid, then use the string reverse again.
This is a method I have found handy for classifying Schools into Elementary, Junior High, Middle, and High Schools, because a list of schools usually has a format like "MARTIN LUTHER KING JR ELEMENTARY SCHOOL" or "JEFFERSON MIDDLE SCHOOL" so the string reverse method gives you an easy way to work from the right to left by reversing the characters so you are actually working left to right, without having to count characters or string parts. Just make sure to reverse the text again so you arent showing anybody information that looks like "LOOHCS ELDDIM NOSREFFFEJ"