Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. arcpy.AddField_management(layerName, "BG10_INT", "LONG", 12, "", "", "", "NULLABLE", "")
  2. expression = "toInt(!BG10!)"
  3. codeblock = """def toInt(value):
  4. if value.isdigit():
  5. return int(value)
  6. else:
  7. return 0"""
  8. arcpy.CalculateField_management (layerName, "BG10_INT", expression, "PYTHON", codeblock)
  9.  
  10. for row in rows:
  11. if row.BG10.isdigit():
  12. row.BG10_INT = int(row.BG10)
  13. else:
  14. row.BG10_INT = 0
  15. rows.updateRow(row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement