Add a features file name to its attribute table?

569
1
08-14-2012 10:24 AM
DavidMedeiros
Occasional Contributor III
I'm wondering if there is a way to populate an attribute field for a feature with that features name?

I have a series of about a thousand polygons as shape-files. The attributes for each are identical, ID 0. But the names are unique, in fact each name encodes 3 attribute values for each feature. I need to merge all of these features into a single feature class but maintain the unique name for each in the new attribute table (to later be parsed into separate fields). Is there a tool or script for adding the name of a feature to its table?
0 Kudos
1 Reply
SolomonPulapkura
Occasional Contributor III
You'd have to do something like
# get the shapefile name

n = arcpy.Describe(shp).name

# open an update cursor

ucur = arcpy.UpdateCursor(shp)

for urow in ucur:
    urow.FCNAME = n # assuming a field called FCNAME exists
    ucur.updateRow(urow)

0 Kudos