I have at my disposal huge amount of data, in the form of a list of tuples. Each tuple has a specified format like (a, b, c, d, e). The list of tuples looks like:
tupleList = [('a1', 'b1', 'c1', 'd1', 'e1'),
('a2', 'b2', 'c2', 'd2', 'e2'),
...
('a10000', 'b10000', 'c10000', 'd10000', 'e100000')]
What I want is, to convert each of these tuples to a dictionary, and append the dictionary to a a final list of dictionaries. Can all this be done in a loop? The final list of dictionaries should look like:
finalDictList = [{'key1': 'a1', 'key2': 'b1', 'key3': 'c1', 'key4': 'd1', 'key5': 'e1'},
{'key1': 'a2', 'key2': 'b2', 'key3': 'c2', 'key4': 'd2', 'key5': 'e2'},
{'key1': 'a3', 'key2': 'b3', 'key3': 'c3', 'key4': 'd3', 'key5': 'e3'},
...
{'key1': 'a10000', 'key2': 'b10000', 'key3': 'c10000', 'key4': 'd10000', 'key5': 'e10000'}]
The format of the tuples is fixed. I want to compare afterwords, value of each key of a dictionary with all others. This is why the conversion of tuple to dictionary made sense to me. Please correct me if the design paradigm itself seems wrong. Also, there are >10000 tuples. Declaring that many dictionaries is just not done.
Is there anyway to append dictionary to a list in a loop? Also, if that is possible, can we access each dictionary by it's key values, say, like finalDictList[0]['key1']?