I inherited a confusing code that to form a table it uses a list of lists to primarily to get data from various sources, then to communicate with other APIs, it transforms into a dictionary which the key is composed from a letter and a number just like in a excel file, an example bellow:
[
[elem1, elem2, elem3...],
[item1, item2, item3...]
[...]
]
transforms into
{
"A1": elem1,
"A2": elem2,
"A3": elem3,
...
"B1": item1,
"B2": item2,
...
}
To make such transformation I've made the following piece of code where the items is the list of list and letters is a list containing the alphabet:
def create_dict(items, letters):
data = {}
for cidx, col in enumerate(items):
for ridx, row in enumerate(col):
data[letters[cidx] + str(ridx + 1)] = row
return data
I know that there are better ways to do this, like using pandas and other things, but I'm trying to preserve the pattern and I'm having difficulties writing the code that makes the other way, which is to consume the dictionary and transform it into a list of lists so other intern APIs can insert more information in this table.