Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Import all functions from arcpy
- from arcpy import *
- #Name of layer
- #!!Change me as needed
- Layer = "TestFC"
- #Fields to check
- #!!Change me as needed too
- SCfields = ["src_RefName", "North", "South", "East", "West"]
- UCfields = ["src_RefName", "n", "s", "e", "w"]
- #Create empty dictionaries
- Ndi = {}
- Sdi = {}
- Edi = {}
- Wdi = {}
- #create SearchCursor object
- cursor = da.SearchCursor (Layer, SCfields)
- #Iterate through rows
- for row in cursor:
- #Dictionary logic tree
- if row[1]:
- if not row[0] in Ndi:
- Ndi[row[0]] = [row[1]]
- else:
- Ndi[row[0]].append(row[1])
- if row[2]:
- if not row[0] in Sdi:
- Sdi[row[0]] = [row[2]]
- else:
- Sdi[row[0]].append(row[2])
- if row[3]:
- if not row[0] in Edi:
- Edi[row[0]] = [row[3]]
- else:
- Edi[row[0]].append(row[3])
- if row[4]:
- if not row[0] in Wdi:
- Wdi[row[0]] = [row[4]]
- else:
- Wdi[row[0]].append(row[4])
- del cursor
- #create UpdateCursor
- cursor = da.UpdateCursor (Layer, UCfields)
- #Iterate through rows
- for row in cursor:
- #Update logic tree
- if row[0] in Ndi:
- row[1] = ",".join(map(str, Ndi[row[0]]))
- if row[0] in Sdi:
- row[2] = ",".join(map(str, Sdi[row[0]]))
- if row[0] in Edi:
- row[3] = ",".join(map(str, Edi[row[0]]))
- if row[0] in Wdi:
- row[4] = ",".join(map(str, Wdi[row[0]]))
- cursor.updateRow(row)
- del cursor
- print "Done"
- SCfields = ["src_RefName", "North", "South", "East", "West"]
- UCfields = ["src_RefName", "n", "s", "e", "w"]
- #Import all functions from arcpy
- from arcpy import *
- #Name of layer
- #!!Change me as needed
- Layer = "TestFC"
- #Fields to check
- #!!Change me as needed too
- SCfields = ["src_RefName", "North"]
- UCfields = ["src_RefName", "n"]
- #Create empty dictionaries
- Ndi = {}
- #create SearchCursor object
- cursor = da.SearchCursor (Layer, SCfields)
- #Iterate through rows
- for row in cursor:
- #Dictionary logic tree
- if row[1]:
- if not row[0] in Ndi:
- Ndi[row[0]] = [row[1]]
- else:
- Ndi[row[0]].append(row[1])
- del cursor
- #create UpdateCursor
- cursor = da.UpdateCursor (Layer, UCfields)
- #Iterate through rows
- for row in cursor:
- #Update logic tree
- if row[0] in Ndi:
- row[1] = ",".join(map(str, Ndi[row[0]]))
- del cursor
- print "Done"
Add Comment
Please, Sign In to add comment