Guest User

Untitled

a guest
Jun 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. #Import all functions from arcpy
  2. from arcpy import *
  3.  
  4. #Name of layer
  5. #!!Change me as needed
  6. Layer = "TestFC"
  7.  
  8. #Fields to check
  9. #!!Change me as needed too
  10. SCfields = ["src_RefName", "North", "South", "East", "West"]
  11. UCfields = ["src_RefName", "n", "s", "e", "w"]
  12.  
  13. #Create empty dictionaries
  14. Ndi = {}
  15. Sdi = {}
  16. Edi = {}
  17. Wdi = {}
  18.  
  19. #create SearchCursor object
  20. cursor = da.SearchCursor (Layer, SCfields)
  21. #Iterate through rows
  22. for row in cursor:
  23. #Dictionary logic tree
  24. if row[1]:
  25. if not row[0] in Ndi:
  26. Ndi[row[0]] = [row[1]]
  27. else:
  28. Ndi[row[0]].append(row[1])
  29. if row[2]:
  30. if not row[0] in Sdi:
  31. Sdi[row[0]] = [row[2]]
  32. else:
  33. Sdi[row[0]].append(row[2])
  34. if row[3]:
  35. if not row[0] in Edi:
  36. Edi[row[0]] = [row[3]]
  37. else:
  38. Edi[row[0]].append(row[3])
  39. if row[4]:
  40. if not row[0] in Wdi:
  41. Wdi[row[0]] = [row[4]]
  42. else:
  43. Wdi[row[0]].append(row[4])
  44.  
  45. del cursor
  46.  
  47. #create UpdateCursor
  48. cursor = da.UpdateCursor (Layer, UCfields)
  49. #Iterate through rows
  50. for row in cursor:
  51. #Update logic tree
  52. if row[0] in Ndi:
  53. row[1] = ",".join(map(str, Ndi[row[0]]))
  54. if row[0] in Sdi:
  55. row[2] = ",".join(map(str, Sdi[row[0]]))
  56. if row[0] in Edi:
  57. row[3] = ",".join(map(str, Edi[row[0]]))
  58. if row[0] in Wdi:
  59. row[4] = ",".join(map(str, Wdi[row[0]]))
  60. cursor.updateRow(row)
  61. del cursor
  62. print "Done"
  63.  
  64. SCfields = ["src_RefName", "North", "South", "East", "West"]
  65. UCfields = ["src_RefName", "n", "s", "e", "w"]
  66.  
  67. #Import all functions from arcpy
  68. from arcpy import *
  69.  
  70. #Name of layer
  71. #!!Change me as needed
  72. Layer = "TestFC"
  73.  
  74. #Fields to check
  75. #!!Change me as needed too
  76. SCfields = ["src_RefName", "North"]
  77. UCfields = ["src_RefName", "n"]
  78.  
  79. #Create empty dictionaries
  80. Ndi = {}
  81.  
  82. #create SearchCursor object
  83. cursor = da.SearchCursor (Layer, SCfields)
  84. #Iterate through rows
  85. for row in cursor:
  86. #Dictionary logic tree
  87. if row[1]:
  88. if not row[0] in Ndi:
  89. Ndi[row[0]] = [row[1]]
  90. else:
  91. Ndi[row[0]].append(row[1])
  92. del cursor
  93.  
  94. #create UpdateCursor
  95. cursor = da.UpdateCursor (Layer, UCfields)
  96. #Iterate through rows
  97. for row in cursor:
  98. #Update logic tree
  99. if row[0] in Ndi:
  100. row[1] = ",".join(map(str, Ndi[row[0]]))
  101. del cursor
  102. print "Done"
Add Comment
Please, Sign In to add comment