NYGeog

Geography, GIS, Geospatial, NYC, etc.

Thursday, January 6, 2011

Python Equivalent to Right( ) in VB for ArcGIS Field Calculator

I'm starting to use Python in the Field Calculator and I just found this out after an hour or so of frustration using rstrip() and rsplit() realized its even easier though not as obvious.

So lets say I wanted to remove the leading character of a 8 digit string in my [UID] field

In VB I'd say:

Right([UID], 7)

In Python I'm saying

!UID![1:]

You may put numbers after the colon [1:4] as well to manipulate the return string lengths and where the string is pulling those lengths from, other than that I don't know but it may help if someone knows the name of this function - if so please comment below?

I posted this to the forum: http://forums.arcgis.com/threads/20620-Python-Field-Calculator-Equivalent-of-Right%28-%29-or-Left%28-%29-in-VB-Field-Calculator?p=66668#post66668