Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -584,60 +584,60 @@ class ReportGenerator:
|
|
584 |
pdf.multi_cell(0, 7, recom_text)
|
585 |
|
586 |
def process_files(html_file, excel_files) -> Tuple[str, str, str]:
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
|
636 |
-
|
637 |
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
|
642 |
def create_interface():
|
643 |
"""Cria a interface Gradio."""
|
|
|
584 |
pdf.multi_cell(0, 7, recom_text)
|
585 |
|
586 |
def process_files(html_file, excel_files) -> Tuple[str, str, str]:
|
587 |
+
"""Processa arquivos e gera relat贸rio."""
|
588 |
+
try:
|
589 |
+
temp_dir = "temp_files"
|
590 |
+
os.makedirs(temp_dir, exist_ok=True)
|
591 |
+
|
592 |
+
# Limpar diret贸rio tempor谩rio
|
593 |
+
for file in os.listdir(temp_dir):
|
594 |
+
os.remove(os.path.join(temp_dir, file))
|
595 |
+
|
596 |
+
# Salvar arquivos
|
597 |
+
html_path = os.path.join(temp_dir, "alunos.htm")
|
598 |
+
with open(html_path, "wb") as f:
|
599 |
+
f.write(html_file)
|
600 |
+
|
601 |
+
# Processar arquivos Excel
|
602 |
+
excel_paths = []
|
603 |
+
for i, excel_file in enumerate(excel_files):
|
604 |
+
excel_path = os.path.join(temp_dir, f"tarefa_{i}.xlsx")
|
605 |
+
with open(excel_path, "wb") as f:
|
606 |
+
f.write(excel_file)
|
607 |
+
excel_paths.append(excel_path)
|
608 |
+
|
609 |
+
# Processar arquivos
|
610 |
+
processor = DataProcessor()
|
611 |
+
alunos_csv_path = os.path.join(temp_dir, "alunos.csv")
|
612 |
+
processor.normalize_html_to_csv(html_path, alunos_csv_path)
|
613 |
+
|
614 |
+
# Concatenar dados das tarefas
|
615 |
+
tarefas_df = pd.DataFrame()
|
616 |
+
for excel_path in excel_paths:
|
617 |
+
csv_path = excel_path.replace('.xlsx', '.csv')
|
618 |
+
processor.normalize_excel_to_csv(excel_path, csv_path)
|
619 |
+
df = pd.read_csv(csv_path)
|
620 |
+
tarefas_df = pd.concat([tarefas_df, df], ignore_index=True)
|
621 |
+
|
622 |
+
# An谩lise e gera莽茫o de relat贸rio
|
623 |
+
alunos_df = pd.read_csv(alunos_csv_path)
|
624 |
+
analyzer = StudentAnalyzer(tarefas_df, alunos_df)
|
625 |
+
results_df = analyzer.prepare_data()
|
626 |
+
|
627 |
+
report_generator = ReportGenerator(results_df)
|
628 |
+
graphs = report_generator.generate_graphs()
|
629 |
|
630 |
+
# Salvar outputs
|
631 |
+
output_html = os.path.join(temp_dir, "relatorio.html")
|
632 |
+
output_pdf = os.path.join(temp_dir, "relatorio.pdf")
|
633 |
+
results_df.to_html(output_html, index=False)
|
634 |
+
report_generator.generate_pdf(output_pdf, graphs)
|
635 |
|
636 |
+
return results_df.to_html(index=False), output_html, output_pdf
|
637 |
|
638 |
+
except Exception as e:
|
639 |
+
logging.error(f"Erro no processamento: {str(e)}")
|
640 |
+
raise
|
641 |
|
642 |
def create_interface():
|
643 |
"""Cria a interface Gradio."""
|