0
I am trying to analyze data from a research of own authorship, the files are already tabulated in .xlsx. format I use openpyxl.
My intention at that time is to take the state of the participants + their opinion and play in a dictionary.
The problem is that this dictionary is returning only 26 items from random positions.
The solution that I seek is: create a dicio with states:opinions with all 318 research participants.
My code:
estados = []
u_opiniao = []
estados_x_opiniao = {}
for rowOfCellObjects in ws['B2':'B319']:
for cellObj in rowOfCellObjects:
valorestado = str(cellObj.value)
estados.append(valorestado)
for rowOfCellObjects in ws['J2':'J319']:
for cellObj in rowOfCellObjects:
opiniao_do_u = str(cellObj.value)
u_opiniao.append(opiniao_do_u)
for i in estados:
estado = i
for i in u_opiniao:
opscen = i
estados_x_opiniao[estado] = opscen
Return
Respostas(total): 318
Total de itens no estados_x_opiniao: 26
In a dictionary you cannot create equal keys with different values. The dictionary defines a 1:1 relational map, so it won’t be possible to do what you want. A simple alternative I see is to define the dictionary with the status as key and a list of comments as value.
– Woss
Great suggestion !
– Lorran Rosa