Below code reads through a Excel datasheet and creates a dictionary. You can reference the values for your key column from the dictionary as key.
import arcpy
import arcgisscripting
gp = arcgisscripting.create()
def Message(sMsg):
print sMsg
gp.AddMessage(sMsg)
# Define the feature class
table = "C:\Users\deenr\Desktop\Data.xlsx\Sheet1$"
keyField = "ID"
keyIdx = -1
fields = arcpy.ListFields(table)
# Get Key column Id
fIdx = 0
for field in fields:
if field.name == keyField:
keyIdx = fIdx
break
fIdx += 1
dictionary = {}
with arcpy.da.SearchCursor(table, ("*")) as cursor:
for row in cursor:
idx = 0
for cell in row:
if idx == fIdx:
if dictionary.has_key(str(cell)) == False:
dictionary[str(cell)] = []
else:
if dictionary.has_key(str(row[fIdx])) == True:
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]))