Skip to content

Instantly share code, notes, and snippets.

@mfurlend
Created January 28, 2014 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfurlend/8670631 to your computer and use it in GitHub Desktop.
Save mfurlend/8670631 to your computer and use it in GitHub Desktop.
For ever layer, set every attribute field's value to the base file name of the layer. Useful for later aggregating by field value.
import arcpy
from arcpy import env
env.workspace = "E:/master_regions"
files = arcpy.ListFiles("*.dbf")
for file in files:
rows = arcpy.UpdateCursor(file)
for row in rows:
row.NAME = file.split('.')[0]
rows.updateRow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment