1

I need to remove whitespace from the end of a string in a field in ArcMap.

I tried first the VBA function RTrim, but whitespace still remained. I thought maybe the whitespaces were tabs, so I tried 'Replace([field], vbTab, ""), but no luck. Then I tried the Python function rstrip, as so:

!FIELDNAME!.rstrip()

..but this resulted in the whitespace being replaced by this character:

Â

There are several of these characters in each of the fields cells trailing the string. I have looked online for some meaning of this symbol, but I haven't found any. Doe anyone know what this means? I have still not successfully removed the trailing whitespace.

here is a screenshot of the attribute column after I run the Python code given above: enter image description here

asked Sep 23, 2013 at 16:00
5
  • 2
    What is the underlying data source format? Shapefile, personal geodatabase, Excel? Commented Sep 23, 2013 at 17:06
  • its a feature class stored in a file geodatabase. I am using ArcMap 10.0, and viewing in map/data in ArcMap/ArcCatalog with ArcView Commented Sep 23, 2013 at 17:50
  • 1
    What is the original source of this data? Those types of characters usually indicate the data were actually encoded, like binary or something. How did it get into the file geodatabase? Also, your statement that the characters are in the field cells trailing each string is confusing. It would help to put up a screenshot of your data. Commented Sep 23, 2013 at 21:29
  • I added a screenshot above (this is the result of running the Python code; the VBA code doesn't seem to do anything that I can see) ... Unfortunately I don't know much about how the data was collected; I would imagine the strings in this column were entered manually but I can't be sure...I will try to trace the source of the data and I will post if I find out. Commented Sep 24, 2013 at 13:10
  • I found that the source of the data is an Excel spreadsheet, and the matching column also has whitespace trailing the string in this column... Commented Sep 24, 2013 at 20:39

1 Answer 1

1

My co-worker came up with this ArcPy script that fixed the problem...it did require making a new field:

arcpy.AddField_management(featureClass, 'MainStreet', 'TEXT')
sCursor = arcpy.SearchCursor(featureClass)
for sRow in sCursor:
 OID = sRow.OBJECTID
 name = sRow.MainSt.encode('ascii', 'ignore')
 query = '"OBJECTID" = ' + str(OID)
 uCursor = arcpy.UpdateCursor(featureClass, query)
 for uRow in uCursor:
 uRow.MainStreet = name
 uCursor.updateRow(uRow)
answered Sep 27, 2013 at 20:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.