Some pointers...
import arcpy
def Message(sMsg):
print sMsg
arcpy.AddMessage(sMsg)
# configuration
table = "C:\Users\deenr\Desktop\Data.xlsx\Sheet1$"
keyField = "ID"
fields = [fld.name for fld in arcpy.ListFields(table)]
fIdx = fields.index(keyField)
dictionary = {}
with arcpy.da.SearchCursor(table, ("*")) as cursor:
for row in cursor:
idx = 0
for cell in row:
if idx == fIdx:
if not str(cell) in dictionary:
dictionary[str(cell)] = []
else:
if str(row[fIdx]) in dictionary:
dictionary[str(row[fIdx])].append(cell)
idx += 1
# Print whole dictionary
Message(str(dictionary.items()))
for key in dictionary.keys():
# Print Values
Message(str(dictionary[key]))
Kind regards, Xander
Hi Xander,
Thanks for the pointers, should agree your code looks more elegant than mine.
Regards
Riyas Deen