I need to write in excel, and I need to know based on the correspondence between groups and names where to write the 'x', so I need a structure where to keep the group name and the corespondent column and rows
n1 - is on row 1 n2 - is on row 2
A(group name) - is on column 2 B(group name) - is on column 3 c- is on column 4 D - is on column 5
I have to set a correspondence between users and groups in a matrix, and writing to excel. The working data:
Groups = A,B,C, D,E, F ...
Name = N1,N2,N3,N4 .....
N1 => A, C,D, F
N2= B,C,D
N3= A, E, F
The expected result is:
A B C D E F
N1 x x x x
N2 x x x
N3 x x x
N1, N2, N3 - are on rows
A,B, c,D - are on columns
I need to write in excel, and I need to know based on the correspondence between groups and names where to write the 'x', so I need a structure where to keep the group name and the corespondent column and rows
N1 - is on row 1
N2 - is on row 2
A(group name) - is on column 2
B(group name) - is on column 3
C is on column 4
D is on column 5
Example:
for N1 I need to write on (row1,col2), (row1,column4), (row1,column5), (row1,column7)
for N2 I need to write on (row2,col3), (row2,column4), (row2,column5)
for N3 I need to write on (row3,col2), (row1,column3), (row1,column6), (row1,column7)
I received the data one by one per user, from a db/csv file. I dont know all the groups at the beginning, I just add unique groups on the columns after I check in their not have been added for a previous user.
If a group is new, not appeared yet, I will add a new column with the group name. If exist I check the position of the group on column and write x in the row.
I tried with using 2 lists or 2 dictionaries, but the correspondence on row I couldn't set it correctly.
for a in b
.....
if group_name not in groups_pos.items():
groups_pos[col_pos] = group_name
name_group[row_pos] = group_name
col_pos += 1
row_pos += 1
......
for col, value in groups_pos.items():
sheet.cell(row=1, column=2+col).value = value
for row, value_p in groups_pos.items():
sheet.cell(row=row, column=2+col).value = 'x'`