I am fairly new to Python and I think this question is fairly easy but I can't figure it out...
I have a data table in excel in which I have B column strings and C through I columns as values. I want to create a dictionary in which for each key value in
B column, I assign values of the columns C through I. I figured out how to do it per row, one at at time but I'm looking for a for loop syntax to do it
throughout the entire excel data table.
Here's my code:
NYSE = {}
NYSE.setdefault(sheet['B5'].value, []).append(sheet['C5'].value)
NYSE.setdefault(sheet['B5'].value, []).append(sheet['D5'].value)
NYSE.setdefault(sheet['B6'].value, []).append(sheet['C6'].value)
NYSE.setdefault(sheet['B6'].value, []).append(sheet['D6'].value)
print NYSE
I can keep manually adding to this...B7 C7, B7 D7, etc, but there must be a way to loop this in a function and output the dictionary.