Guest User

Untitled

a guest
Dec 10th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. VSG_ALL = VSG_EINZEL + VSG_EINZEL_1 + VSG_EINZEL_12
  2.  
  3. import arcpy
  4. # use workspace env or give an absolute path for fc
  5. arcpy.env.workspace = "workspace"
  6. fc = "feature_class"
  7.  
  8. # making a list of fields that contain VSG_EIZEL
  9. # ex VSG_EINZEL, VSG_EIZEL_1, VSG_EIZEL_2
  10. field_prefix = "VSG_EINZEL"
  11. field_list = []
  12. f_list = arcpy.ListFields(fc)
  13. for f in f_list:
  14. if field_prefix in f.name:
  15. field_list.append(f.name)
  16.  
  17. # use update cursor to find values
  18. # and update the total field
  19. rows = arcpy.UpdateCursor(fc)
  20. for row in rows:
  21. VSG_SUM = 0
  22. for f in field_list:
  23. VSG_SUM += row.getValue(f)
  24. row.VSG_ALL = VSG_SUM
  25. rows.updateRow(row)
  26. del VSG_SUM
  27. del rows
Add Comment
Please, Sign In to add comment