Tengo dos archivos pickle, Airline_XYZ.p
:
[{}, {}, {'Gender *': ['Female', 'Male', 'Autre :'], 'Please provide your age in years. *': [], 'Please indicate your country of residence. *': [], 'For respondents from the United States, please provide the ZIP c
ode of your primary residence *': [], 'If you are an Amazon Mturk worker, please provide your ID below. If you are not an Mturk worker, please type NULL *': []}, {}]
y Hotel_Chain_ABC.p
:
[{}, {'How can we make your hotel shuttle trip, post COVID-19': ['Private shuttle', 'Shuttle with passenger limits', 'Protective glass arou
nd each seat', "Disposable PPE's onboard", 'Sanitizer onboard', "Driver in full PPE's", 'Other:'], 'How can we make you feel safe in our Hotel/Motel post COVID-19': ['Electronic doors', "Employees in full PPE's",
'Limits on the amount of people in Lobby', 'Protective glass at check-in station', 'A way to enter your room without key cards or keys', 'Have sheets and towels enclosed in individual plastic covering', 'Other:']]
Me gustaría hacer un csv de ellos con las siguientes columnas pickle_file_name
, question
, answer1
, answer2
, answer_3
, ... para cada respuestas para una pregunta
Hasta ahora sé cómo extraer la pregunta y las respuestas:
>>> all_questions = pickle.load( open( "Airline_XYZ.p", "rb" ) )
>>> l_question = []
>>> for element in all_questions:
... for question in element:
... l_question.append({"question": question, "answer": element[question]})
...
No sé cómo crear los diferentes answer_i
columnas, ni cómo insertarlos con el otro en un csv.