a guest Dec 10th, 2018 57 Never
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:
- # 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
- del VSG_SUM
- del rows
RAW Paste Data