datawiser / qual2db

Python code for extracting data from the Qualtrics API and posting to a MySQL database
8 stars 8 forks source link

"list index out of range" error in qualInterface.py line 313 #2

Open datawiser opened 8 years ago

datawiser commented 8 years ago

Example error from PyCharm debug output (same problem has occurred with other surveys):

Adding "CSR1067 Survey 2" to MySQL... Retrieving "CSR1067 Survey 2" Uploading "CSR1067 Survey 2" aligned with sql. Gathering qualtrics data. 341 new respondents. Exception in Tkinter callback Traceback (most recent call last): File "C:\Python27\lib\lib-tk\Tkinter.py", line 1536, in call Building responses list. return self.func(*args) File "R:/CSR/Admin/Computing/Software/Qualtrics/qual2db\qual2db\thegui.py", line 321, in addEvent add() File "R:/CSR/Admin/Computing/Software/Qualtrics/qual2db\qual2db\thegui.py", line 339, in add s.update_sql() File "R:/CSR/Admin/Computing/Software/Qualtrics/qual2db\qual2db\survey.py", line 95, in update_sql self.responses = self.qualInterface.processResponses(self,self.sqlid,debug=debug) File "R:/CSR/Admin/Computing/Software/Qualtrics/qual2db\qual2db\qualInterface.py", line 313, in processResponses question_type = [x[2] for x in qkey if x[1]==qid][0] IndexError: list index out of range

datawiser commented 8 years ago

This problem is common enough that qual2db should handle it gracefully, even though the fault may be with the Qualtrics survey designer. More soon when we remember how to solve this problem.

datawiser commented 8 years ago

@oaselles, I'm just experimenting with using GitHub issues, so take my "assignment" of this issue to you casually.

oaselles commented 8 years ago

Can you share an empty copy of the survey with me on Qualtrics? My username should be oselles@wisc.edu.

datawiser commented 8 years ago

Just did so! Thanks!

oaselles commented 8 years ago

Cool, I'll take a look at it. That error message is usually associated with a question type qual2db isn't prepared to handle, so I'll try to fix the code this evening.

datawiser commented 8 years ago

It would be enough here to just report out the part of the data or schema that is throwing the error. I'm using PyCharm Community Edition debug, which is where I got the console excerpt above.

datawiser commented 8 years ago

@oaselles Alert--we've diagnosed the specific problem. We had a recoded question in the survey. Removing it gets rid of the problem. A nice fix to this bug would be code that alerts the user to the specific problem and suggests checking for recodes. Even better would be to gracefully skip the recoded data and complete the update with notice of the error.

oaselles commented 8 years ago

Oh, yeah that would be a problem. Recoded questions really mess things up in the underlying data structure that comes from Qualtrics and undermine how qual2db works entirely. I've tried to tackle this before, but just decided to call it a limitation. It might be mentioned in the Wiki already. I can try to look at this problem again and at least find a way to alert the user that a recode is causing the problem.

datawiser commented 8 years ago

Thanks, Owen. Note that child nodes in Qualtrics XML are the problem with scoring variables as well.