def __row_to_contest(self, row): contest = Contest() contest.title = row[self.__csv_format['QUESTION_COL_INDEX']] for index in self.__csv_format['OPTIONS_COL_INDEXES']: option = Choice() option.title = row[index] contest.options.append(option) if index == self.__csv_format['RESPONSE_COL_INDEX']: contest.response_index = len(contest.options) - 1 if contest.response_index is None: raise Exception('Response index must be in the options list') return contest