со ссылкой на Как я могу отображать данные в таблице в столбцах, а не в строке?
я сделал это здесь, мой код
col1 = ['SUBJECT NAME'] + ['SUBJECT {}'.format(x) for x in range(1, thr_l+1)] + ['Practical {}'.format(y) for y in range(1, prac_l+1)] + [g_t]
col2 = ['GRADE'] + [grade_thr[i] for i in range(len(grade_thr)-1)] + [grade_prac[i] for i in range(len(grade_prac))] + [grade_thr[len(grade_thr)-1]]
col3 = ['GRADE POINTS'] + [grade_points_thr[i] for i in range(len(grade_points_thr)-1)] + [grade_points_prac[i] for i in range(len(grade_prac))] + [grade_points_thr[len(grade_thr)-1]]
col4 = ['CREDITS'] + [crd_thr_list_int[i] for i in range(len(crd_thr_list_int)-1)] + [crd_prac_list_int[i] for i in range(len(crd_prac_list_int))] + [crd_thr_list_int[len(crd_thr_list_int)-1]]
data1 = [col1, col2, col3, col4]
from reportlab.platypus import Table
table = Table(zip(*data1))
from reportlab.platypus import TableStyle
from reportlab.lib import colors
style = TableStyle([
('BACKGROUND', (0,0), (3,0), colors.green),
('TEXTCOLOR',(0,0),(-1,0),colors.whitesmoke),
('ALIGN',(0,0),(-1,-1),'CENTER'),
('FONTNAME', (0,0), (-1,0), 'Courier-Bold'),
('FONTSIZE', (0,0), (-1,0), 14),
('BOTTOMPADDING', (0,0), (-1,0), 12),
('BACKGROUND',(0,1),(-1,-1),colors.beige),
])
table.setStyle(style)
rowNumb = len(data1)
for i in range(1, rowNumb):
if i % 2 == 0:
bc = colors.burlywood
else:
bc = colors.beige
ts = TableStyle(
[('BACKGROUND', (0,i),(-1,i), bc)]
)
table.setStyle(ts)
ts = TableStyle([
('BOX',(0,0),(-1,-1),2,colors.black),
('LINEBEFORE',(2,1),(2,-1),2,colors.red),
('LINEABOVE',(0,2),(-1,2),2,colors.green),
('GRID',(0,1),(-1,-1),2,colors.black),
])
table.setStyle(ts)
MARGIN_LEFT = 50
MARGIN_BOTTOM = 400
table.wrapOn(pdf, 0, 0)
table.drawOn(pdf, MARGIN_LEFT, MARGIN_BOTTOM)
pdf.save()
но теперь я Я получаю сообщение об ошибке
Ошибка Value: Table@0x1AB4FD33780 неизвестные строки x неизвестные столбцы ... неверный тип данных
Скажите, пожалуйста, как я могу это исправить, спасибо