I am trying to calculate a field using part of the feature class path name (specifically, the last three characters of the geodatabase name). Is this possible? I've tried using the parse path tool and including the value as an inline variable subsitution with the VB string right function. Perhaps a more complicated Python script is neccessary?
with Python (you'll need to define workspace, the script loops on all feature classes in the workspace and update the field with the last three characters of its name :
fcs = arcpy.ListFeatureClasses() for fc in fcs: arcpy.CalculateField_management(fc, "field_to_update", "'" + fc[-3:] + "'", "PYTHON")
EDIT : for the gdb name , the expression would be
expression = arcpy.Describe(fc).catalogPath.split(".gdb")[:-3]