I'm working with openpyxl to read and write xlsx files, for some data manipulation purposes I need to translate my worksheet (which I have represented in a 2D matrix) into a dictionary which follows a specific format, here is my matrix.
[['Name', 'Age', 'Gender', 'Height', 'Hair Color'],
['Jay', '12', 'M', '123cm', 'Black'],
['Marie', '13', 'F', '100cm', 'Red'],
['Dan', '16', 'M', '200cm', 'Brown']
]
I'd like to translate this so that the resulting dictionary looks like:
{
{ 'Jay;12;M' : 'Name': 'Jay', 'Age': '12', 'Gender': 'M', 'Height': '123cm', 'Hair Color' : 'Black'},
{ 'Marie;13;F' : 'Name': 'Marie', 'Age': '13', 'Gender': 'F', 'Height': '100cm', 'Hair Color' : 'Red'},
{ 'Dan;16;M' : 'Name': 'Dan', 'Age': '16', 'Gender': 'M', 'Height': '200cm', 'Hair Color' : 'Brown'},
}
I'm relatively new to Python and I believe a dictionary comprehension is the way to go but I'm not exactly sure how to get these 2D array values by name so I can build my key value pairs properly.