Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VSG_ALL = VSG_EINZEL + VSG_EINZEL_1 + VSG_EINZEL_12
- import arcpy
- # use workspace env or give an absolute path for fc
- arcpy.env.workspace = "workspace"
- fc = "feature_class"
- # making a list of fields that contain VSG_EIZEL
- # ex VSG_EINZEL, VSG_EIZEL_1, VSG_EIZEL_2
- field_prefix = "VSG_EINZEL"
- field_list = []
- f_list = arcpy.ListFields(fc)
- for f in f_list:
- if field_prefix in f.name:
- field_list.append(f.name)
- # use update cursor to find values
- # and update the total field
- rows = arcpy.UpdateCursor(fc)
- for row in rows:
- VSG_SUM = 0
- for f in field_list:
- VSG_SUM += row.getValue(f)
- row.VSG_ALL = VSG_SUM
- rows.updateRow(row)
- del VSG_SUM
- del rows
Add Comment
Please, Sign In to add comment