Set-up
I am reading a google sheet with python. The sheet contains answers from a google form questionary.
Each row in the sheet is one participant, and all columns are the participant's answers to the questions.
Problem
I use logic in the google form which leads to a lot of empty rows – skipping sections in the google form creates empty answers in the sheet.
E.g. sheet looks like,
Q1 | Q2 | Q3 | Q4
-----------------
A1 | | A2 | A3
| A1 | | A2
A1 | A2 | A3 | A4
I do not care about the empty answers and tell Python to disregard them in the following way,
list(filter(None, sheet.row_values(2)))
where sheet refers to the google sheet.
The above command provides me a list of all the answers of one participant, without empty rows.
The result for the three participant looks like,
p1 = ['A1','A2', 'A3']
p2 = ['A1','A2']
p3 = ['A1','A2', 'A3', 'A4']
However, I do not know which questions the answers answer. Is there a way to command Python to disregard all empty columns for a specific row and yield the accompanying non-empty column names? The column names are in row 1.
Preferably, I obtain dictionaries like,
p1 = {'Q1':'A1', 'Q3':'A2', 'Q4':A3}
p2 = {'Q2':'A1', 'Q4':'A2'}
p3 = {'Q1':'A1', 'Q2':'A2', 'Q3':'A3', 'Q4':'A4'}
How to do this?