{ "cells": [ { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from pptx import Presentation\n", "from pptx.util import Inches\n", "import os\n", "from pptx.enum.text import MSO_VERTICAL_ANCHOR\n", "from pptx.enum.text import PP_ALIGN\n", "from pptx.util import Pt\n", "import tkinter as tk\n", "from tkinter import filedialog" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "excel = filedialog.askopenfilename(filetypes=[(\"Excel files\", \"*.xlsx\")])\n", "df=pd.read_excel(excel)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\garci\\AppData\\Local\\Temp\\ipykernel_37164\\1777971816.py:18: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`\n", " df.fillna(0, inplace=True)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
NumeroNomeCitaçãoRef ElLouvor DiretorLouvor \\nCmdt CAlLouvor \\nCmdt CompRepreensão SimplesRepreensão RegistadaNota QuatitativaNota QualitativaSuspensão Frequência
346Garrinhas010000016.00BOM0
461Oliviera000000015.00BOM0
568Vasconcelos000000015.00BOM0
6102Marques000000018.00MUITO BOM0
7113Alves000000013.94SUFICIENTE0
8145Grazina000000013.94SUFICIENTE0
9161Borges100000019.00MUITO BOM0
10343Leite000000017.66BOM0
11454Figueiredo000000019.00MUITO BOM0
12475Raposo100000017.80BOM0
13477Boita000000019.00MUITO BOM0
14495Carvalho000000016.00BOM0
15514Batista000000017.49BOM0
16536Sendim000000013.94SUFICIENTE0
17740Damião000000016.46BOM0
18757Serrão000000019.00MUITO BOM0
190000000000.0000
200000000000.0000
210000000000.0000
220000000000.0000
230000000000.0000
\n", "
" ], "text/plain": [ "0 Numero Nome Citação Ref El Louvor Diretor Louvor \\nCmdt CAl \\\n", "3 46 Garrinhas 0 1 0 0 \n", "4 61 Oliviera 0 0 0 0 \n", "5 68 Vasconcelos 0 0 0 0 \n", "6 102 Marques 0 0 0 0 \n", "7 113 Alves 0 0 0 0 \n", "8 145 Grazina 0 0 0 0 \n", "9 161 Borges 1 0 0 0 \n", "10 343 Leite 0 0 0 0 \n", "11 454 Figueiredo 0 0 0 0 \n", "12 475 Raposo 1 0 0 0 \n", "13 477 Boita 0 0 0 0 \n", "14 495 Carvalho 0 0 0 0 \n", "15 514 Batista 0 0 0 0 \n", "16 536 Sendim 0 0 0 0 \n", "17 740 Damião 0 0 0 0 \n", "18 757 Serrão 0 0 0 0 \n", "19 0 0 0 0 0 0 \n", "20 0 0 0 0 0 0 \n", "21 0 0 0 0 0 0 \n", "22 0 0 0 0 0 0 \n", "23 0 0 0 0 0 0 \n", "\n", "0 Louvor \\nCmdt Comp Repreensão Simples Repreensão Registada \\\n", "3 0 0 0 \n", "4 0 0 0 \n", "5 0 0 0 \n", "6 0 0 0 \n", "7 0 0 0 \n", "8 0 0 0 \n", "9 0 0 0 \n", "10 0 0 0 \n", "11 0 0 0 \n", "12 0 0 0 \n", "13 0 0 0 \n", "14 0 0 0 \n", "15 0 0 0 \n", "16 0 0 0 \n", "17 0 0 0 \n", "18 0 0 0 \n", "19 0 0 0 \n", "20 0 0 0 \n", "21 0 0 0 \n", "22 0 0 0 \n", "23 0 0 0 \n", "\n", "0 Nota Quatitativa Nota Qualitativa Suspensão Frequência \n", "3 16.00 BOM 0 \n", "4 15.00 BOM 0 \n", "5 15.00 BOM 0 \n", "6 18.00 MUITO BOM 0 \n", "7 13.94 SUFICIENTE 0 \n", "8 13.94 SUFICIENTE 0 \n", "9 19.00 MUITO BOM 0 \n", "10 17.66 BOM 0 \n", "11 19.00 MUITO BOM 0 \n", "12 17.80 BOM 0 \n", "13 19.00 MUITO BOM 0 \n", "14 16.00 BOM 0 \n", "15 17.49 BOM 0 \n", "16 13.94 SUFICIENTE 0 \n", "17 16.46 BOM 0 \n", "18 19.00 MUITO BOM 0 \n", "19 0.00 0 0 \n", "20 0.00 0 0 \n", "21 0.00 0 0 \n", "22 0.00 0 0 \n", "23 0.00 0 0 " ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "linha_juntada = df.loc[0].combine_first(df.loc[1])\n", "df.loc[0] = linha_juntada\n", "df.columns = df.iloc[0]\n", "df = df.drop(index=[0, 1])\n", "df = df[1:]\n", "df = df.drop(columns=['Camaradagem','Total (Máx 6)', 'Sentido de Responsabilidade','Honestidade','Aplicação', 'Civilidade', 'Aprumo e Atavio','Pontualidade'])\n", "df = df.rename(columns={'Coluna1': 'NovaColuna1', 'Coluna3': 'NovaColuna3'})\n", "df.columns.values[0] = 'Numero'\n", "df.columns.values[1] = 'Nome'\n", "df.columns.values[2] = 'Nota Graduados'\n", "df.columns.values[11] = 'Apagar1'\n", "df.columns.values[13] = 'Apagar2'\n", "df.columns.values[14] = 'Apagar3'\n", "df.columns.values[15] = 'Nota Quatitativa'\n", "df.columns.values[16] = 'Nota Qualitativa'\n", "df.columns.values[17] = 'Apagar4'\n", "df['Nota Quatitativa']=df['Nota Quatitativa'].round(2)\n", "df.fillna(0, inplace=True)\n", "df['Suspensão Frequência'] = df['Suspensão Frequência (1)'] + df['Suspensão Frequência (2)']\n", "df = df.drop(columns=['Nota Graduados','Apagar1', 'Apagar2','Apagar3','Apagar4', 'Suspensão Frequência (1)', 'Suspensão Frequência (2)'])\n", "df\n" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "Alunosmtbom = df[df['Nota Qualitativa'] == 'MUITO BOM']\n", "Alunossuf = df[df['Nota Qualitativa'] == 'SUFICIENTE']\n", "Alunosmed = df[df['Nota Qualitativa'] == 'MEDIOCRE']\n", "Alunosmau = df[df['Nota Qualitativa'] == 'MAU']" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Foto do aluno 0 não encontrada.\n", "Nenhum aluno com 'MEDIOCRE' encontrado.\n", "Nenhum aluno com 'MAU' encontrado.\n", "Arquivo PowerPoint atualizado salvo em: Apresentação Comportamentos2.pptx\n" ] } ], "source": [ "numero_aluno = df.loc[df['Nota Qualitativa'] == 'MUITO BOM', 'Numero'].values\n", "def get_safe_value(lista, indice, valor_padrao=0):\n", " return lista[indice] if indice < len(lista) else valor_padrao\n", "numero_aluno_0 = get_safe_value(numero_aluno, 0)\n", "numero_aluno_1 = get_safe_value(numero_aluno, 1)\n", "numero_aluno_2 = get_safe_value(numero_aluno, 2)\n", "numero_aluno_3 = get_safe_value(numero_aluno, 3)\n", "numero_aluno_4 = get_safe_value(numero_aluno, 4)\n", "\n", "caminho_pptx = 'Apresentação Comportamentos.pptx'\n", "caminho_fotos = 'Fotos' \n", "presentation = Presentation(caminho_pptx)\n", "if numero_aluno_0 is not None:\n", " for slide in presentation.slides:\n", " for shape in slide.shapes:\n", " if shape.has_text_frame:\n", " for paragraph in shape.text_frame.paragraphs:\n", " for run in paragraph.runs:\n", " if \"N1\" in run.text:\n", " run.text = run.text.replace(\"N1\", str(numero_aluno_0))\n", " foto_aluno_0 = os.path.join(caminho_fotos, f\"{numero_aluno_0}.JPG\")\n", " if os.path.exists(foto_aluno_0):\n", " slide.shapes.add_picture(foto_aluno_0, Inches(0), Inches(2.8), width=Inches(2), height=Inches(3))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno_0} não encontrada.\") \n", " if \"N2\" in run.text and numero_aluno_1 is not None:\n", " run.text = run.text.replace(\"N2\", str(numero_aluno_1))\n", " foto_aluno_1 = os.path.join(caminho_fotos, f\"{numero_aluno_1}.JPG\")\n", " if os.path.exists(foto_aluno_1):\n", " slide.shapes.add_picture(foto_aluno_1, Inches(2), Inches(2.8), width=Inches(2), height=Inches(3))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno_1} não encontrada.\")\n", " if \"NN\" in run.text and numero_aluno_2 is not None:\n", " run.text = run.text.replace(\"NN\", str(numero_aluno_2))\n", " foto_aluno_2 = os.path.join(caminho_fotos, f\"{numero_aluno_2}.JPG\")\n", " if os.path.exists(foto_aluno_2):\n", " slide.shapes.add_picture(foto_aluno_2, Inches(4), Inches(2.8), width=Inches(2), height=Inches(3))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno_2} não encontrada.\")\n", " if \"NX\" in run.text and numero_aluno_3 is not None:\n", " run.text = run.text.replace(\"NX\", str(numero_aluno_3))\n", " foto_aluno_3 = os.path.join(caminho_fotos, f\"{numero_aluno_3}.JPG\")\n", " if os.path.exists(foto_aluno_3):\n", " slide.shapes.add_picture(foto_aluno_3, Inches(6), Inches(2.8), width=Inches(2), height=Inches(3))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno_3} não encontrada.\")\n", " if \"PP\" in run.text and numero_aluno_4 is not None:\n", " run.text = run.text.replace(\"PP\", str(numero_aluno_4))\n", " foto_aluno_4 = os.path.join(caminho_fotos, f\"{numero_aluno_4}.JPG\")\n", " if os.path.exists(foto_aluno_4):\n", " slide.shapes.add_picture(foto_aluno_4, Inches(8), Inches(2.8), width=Inches(2), height=Inches(3))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno_4} não encontrada.\")\n", "\n", "numero_aluno1 = df.loc[df['Nota Qualitativa'] == 'SUFICIENTE', 'Numero'].values\n", "rs=df.loc[df['Nota Qualitativa'] == 'SUFICIENTE', 'Repreensão Simples'].values\n", "ra=df.loc[df['Nota Qualitativa'] == 'SUFICIENTE', 'Repreensão Registada'].values\n", "sf=df.loc[df['Nota Qualitativa'] == 'SUFICIENTE', 'Suspensão Frequência'].values\n", "numero_aluno1_0 = get_safe_value(numero_aluno1, 0)\n", "numero_aluno1_1 = get_safe_value(numero_aluno1, 1)\n", "numero_aluno1_2 = get_safe_value(numero_aluno1, 2)\n", "numero_aluno1_3 = get_safe_value(numero_aluno1, 3)\n", "numero_aluno1_4 = get_safe_value(numero_aluno1, 4)\n", "if numero_aluno1_0 is not None:\n", " for slide in presentation.slides:\n", " for shape in slide.shapes:\n", " if shape.has_text_frame:\n", " for paragraph in shape.text_frame.paragraphs:\n", " for run in paragraph.runs:\n", " if \"N3\" in run.text:\n", " run.text = run.text.replace(\"N3\", str(numero_aluno1_0))\n", " foto_aluno1_0 = os.path.join(caminho_fotos, f\"{numero_aluno1_0}.JPG\")\n", " if os.path.exists(foto_aluno1_0):\n", " slide.shapes.add_picture(foto_aluno1_0, Inches(0.2), Inches(1.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_0} não encontrada.\")\n", " if \"N4\" in run.text and numero_aluno1_1 is not None:\n", " run.text = run.text.replace(\"N4\", str(numero_aluno1_1))\n", " foto_aluno1_1 = os.path.join(caminho_fotos, f\"{numero_aluno1_1}.JPG\")\n", " if os.path.exists(foto_aluno1_1):\n", " slide.shapes.add_picture(foto_aluno1_1, Inches(0.2), Inches(4.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_1} não encontrada.\")\n", " if \"AA\" in run.text:\n", " run.text = run.text.replace(\"AA\", str(numero_aluno1_2))\n", " foto_aluno1_2 = os.path.join(caminho_fotos, f\"{numero_aluno1_2}.JPG\")\n", " if os.path.exists(foto_aluno1_2):\n", " slide.shapes.add_picture(foto_aluno1_2, Inches(0.2), Inches(1.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_2} não encontrada.\")\n", " if \"AB\" in run.text and numero_aluno1_3 is not None:\n", " run.text = run.text.replace(\"AB\", str(numero_aluno1_3))\n", " foto_aluno1_3 = os.path.join(caminho_fotos, f\"{numero_aluno1_3}.JPG\")\n", " if os.path.exists(foto_aluno1_3):\n", " slide.shapes.add_picture(foto_aluno1_3, Inches(0.2), Inches(4.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_3} não encontrada.\")\n", " if shape.has_table: \n", " table = shape.table\n", " for row in table.rows:\n", " for cell in row.cells: \n", " if \"RS1\" in cell.text:\n", " cell.text = cell.text.replace(\"RS1\", str(rs[0]) if len(rs) > 0 else \"0\")\n", " if \"RS2\" in cell.text:\n", " cell.text = cell.text.replace(\"RS2\", str(rs[1]) if len(rs) > 1 else \"0\")\n", " if \"RA1\" in cell.text:\n", " cell.text = cell.text.replace(\"RA1\", str(ra[0]) if len(ra) > 0 else \"0\")\n", " if \"RA2\" in cell.text:\n", " cell.text = cell.text.replace(\"RA2\", str(ra[1]) if len(ra) > 1 else \"0\")\n", " if \"SF1\" in cell.text:\n", " cell.text = cell.text.replace(\"SF1\", str(sf[0]) if len(sf) > 0 else \"0\")\n", " if \"SF2\" in cell.text:\n", " cell.text = cell.text.replace(\"SF2\", str(sf[1]) if len(sf) > 1 else \"0\")\n", " if \"RSAA1\" in cell.text:\n", " cell.text = cell.text.replace(\"RSAA1\", str(rs[0]) if len(rs) > 0 else \"0\")\n", " if \"RSAA2\" in cell.text:\n", " cell.text = cell.text.replace(\"RSAA2\", str(rs[1]) if len(rs) > 1 else \"0\")\n", " if \"RAAA1\" in cell.text:\n", " cell.text = cell.text.replace(\"RAAA1\", str(ra[0]) if len(ra) > 0 else \"0\")\n", " if \"RAAA2\" in cell.text:\n", " cell.text = cell.text.replace(\"RAAA2\", str(ra[1]) if len(ra) > 1 else \"0\")\n", " if \"SFAA1\" in cell.text:\n", " cell.text = cell.text.replace(\"SFAA1\", str(sf[0]) if len(sf) > 0 else \"0\")\n", " if \"SFAA2\" in cell.text:\n", " cell.text = cell.text.replace(\"SFAA2\", str(sf[1]) if len(sf) > 1 else \"0\")\n", " cell.text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER \n", " cell.text_frame.vertical_anchor = MSO_VERTICAL_ANCHOR.MIDDLE \n", " \n", " \n", "numero_aluno2 = df.loc[df['Nota Qualitativa'] == 'MEDIOCRE', 'Numero'].values\n", "rs2=df.loc[df['Nota Qualitativa'] == 'MEDIOCRE', 'Repreensão Simples'].values\n", "ra2=df.loc[df['Nota Qualitativa'] == 'MEDIOCRE', 'Repreensão Registada'].values\n", "sf2=df.loc[df['Nota Qualitativa'] == 'MEDIOCRE', 'Suspensão Frequência'].values\n", "if len(numero_aluno2) >= 2:\n", " numero_aluno1_0 = numero_aluno2[0]\n", " numero_aluno1_1 = numero_aluno2[1]\n", "elif len(numero_aluno2) == 1:\n", " numero_aluno1_0 = numero_aluno2[0]\n", " numero_aluno1_1 = None\n", "else:\n", " print(\"Nenhum aluno com 'MEDIOCRE' encontrado.\")\n", " numero_aluno1_0 = None\n", " numero_aluno1_1 = None\n", "if numero_aluno1_0 is not None:\n", " for slide in presentation.slides:\n", " for shape in slide.shapes:\n", " if shape.has_text_frame:\n", " for paragraph in shape.text_frame.paragraphs:\n", " for run in paragraph.runs:\n", " if \"N5\" in run.text:\n", " run.text = run.text.replace(\"N5\", str(numero_aluno1_0))\n", " foto_aluno1_0 = os.path.join(caminho_fotos, f\"{numero_aluno1_0}.JPG\")\n", " if os.path.exists(foto_aluno1_0):\n", " slide.shapes.add_picture(foto_aluno1_0, Inches(0.2), Inches(1.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_0} não encontrada.\")\n", " if \"N6\" in run.text and numero_aluno1_1 is not None:\n", " run.text = run.text.replace(\"N6\", str(numero_aluno1_1))\n", " foto_aluno1_1 = os.path.join(caminho_fotos, f\"{numero_aluno1_1}.JPG\")\n", " if os.path.exists(foto_aluno1_1):\n", " slide.shapes.add_picture(foto_aluno1_1, Inches(0.2), Inches(4.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_1} não encontrada.\")\n", " if shape.has_table: \n", " table = shape.table\n", " for row in table.rows:\n", " for cell in row.cells: \n", " if \"RS3\" in cell.text:\n", " cell.text = cell.text.replace(\"RS3\", str(rs2[0]) if len(rs2) > 0 else \"0\")\n", " if \"RS4\" in cell.text:\n", " cell.text = cell.text.replace(\"RS4\", str(rs2[1]) if len(rs2) > 1 else \"0\")\n", " if \"RA3\" in cell.text:\n", " cell.text = cell.text.replace(\"RA3\", str(ra2[0]) if len(ra2) > 0 else \"0\")\n", " if \"RA4\" in cell.text:\n", " cell.text = cell.text.replace(\"RA4\", str(ra2[1]) if len(ra2) > 1 else \"0\")\n", " if \"SF3\" in cell.text:\n", " cell.text = cell.text.replace(\"SF3\", str(sf2[0]) if len(sf2) > 0 else \"0\")\n", " if \"SF4\" in cell.text:\n", " cell.text = cell.text.replace(\"SF4\", str(sf2[1]) if len(sf2) > 1 else \"0\") \n", " cell.text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER \n", " cell.text_frame.vertical_anchor = MSO_VERTICAL_ANCHOR.MIDDLE\n", "\n", "numero_aluno3 = df.loc[df['Nota Qualitativa'] == 'MAU', 'Numero'].values\n", "rs3=df.loc[df['Nota Qualitativa'] == 'MAU', 'Repreensão Simples'].values\n", "ra3=df.loc[df['Nota Qualitativa'] == 'MAU', 'Repreensão Registada'].values\n", "sf3=df.loc[df['Nota Qualitativa'] == 'MAU', 'Suspensão Frequência'].values\n", "if len(numero_aluno3) >= 2:\n", " numero_aluno1_0 = numero_aluno3[0]\n", " numero_aluno1_1 = numero_aluno3[1]\n", "elif len(numero_aluno3) == 1:\n", " numero_aluno1_0 = numero_aluno3[0]\n", " numero_aluno1_1 = None\n", "else:\n", " print(\"Nenhum aluno com 'MAU' encontrado.\")\n", " numero_aluno1_0 = None\n", " numero_aluno1_1 = None\n", "if numero_aluno1_0 is not None:\n", " for slide in presentation.slides:\n", " for shape in slide.shapes:\n", " if shape.has_text_frame:\n", " for paragraph in shape.text_frame.paragraphs:\n", " for run in paragraph.runs:\n", " if \"N7\" in run.text:\n", " run.text = run.text.replace(\"N7\", str(numero_aluno1_0))\n", " foto_aluno1_0 = os.path.join(caminho_fotos, f\"{numero_aluno1_0}.JPG\")\n", " if os.path.exists(foto_aluno1_0):\n", " slide.shapes.add_picture(foto_aluno1_0, Inches(0.2), Inches(1.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_0} não encontrada.\")\n", " if \"N8\" in run.text and numero_aluno1_1 is not None:\n", " run.text = run.text.replace(\"N8\", str(numero_aluno1_1))\n", " foto_aluno1_1 = os.path.join(caminho_fotos, f\"{numero_aluno1_1}.JPG\")\n", " if os.path.exists(foto_aluno1_1):\n", " slide.shapes.add_picture(foto_aluno1_1, Inches(0.2), Inches(4.5), width=Inches(1.5), height=Inches(2.2))\n", " else:\n", " print(f\"Foto do aluno {numero_aluno1_1} não encontrada.\")\n", " if shape.has_table: \n", " table = shape.table\n", " for row in table.rows:\n", " for cell in row.cells: \n", " if \"RS5\" in cell.text:\n", " cell.text = cell.text.replace(\"RS5\", str(rs3[0]) if len(rs3) > 0 else \"0\")\n", " if \"RS6\" in cell.text:\n", " cell.text = cell.text.replace(\"RS6\", str(rs3[1]) if len(rs3) > 1 else \"0\")\n", " if \"RA5\" in cell.text:\n", " cell.text = cell.text.replace(\"RA5\", str(ra3[0]) if len(ra3) > 0 else \"0\")\n", " if \"RA6\" in cell.text:\n", " cell.text = cell.text.replace(\"RA6\", str(ra3[1]) if len(ra3) > 1 else \"0\")\n", " if \"SF5\" in cell.text:\n", " cell.text = cell.text.replace(\"SF5\", str(sf3[0]) if len(sf3) > 0 else \"0\")\n", " if \"SF6\" in cell.text:\n", " cell.text = cell.text.replace(\"SF6\", str(sf3[1]) if len(sf3) > 1 else \"0\")\n", " cell.text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER \n", " cell.text_frame.vertical_anchor = MSO_VERTICAL_ANCHOR.MIDDLE\n", "MT1 = df['Nota Qualitativa'].value_counts().get('MUITO BOM', 0) \n", "B1 = df['Nota Qualitativa'].value_counts().get('BOM', 0)\n", "S1 = df['Nota Qualitativa'].value_counts().get('SUFICIENTE', 0) \n", "M1 = df['Nota Qualitativa'].value_counts().get('MEDIOCRE', 0)\n", "MAU1 = df['Nota Qualitativa'].value_counts().get('MAU', 0)\n", "moda = df['Nota Qualitativa'].mode()\n", "\n", "for slide in presentation.slides:\n", " for shape in slide.shapes:\n", " if shape.has_table: \n", " table = shape.table\n", " for row in table.rows:\n", " for cell in row.cells: \n", " if \"MT1\" in cell.text:\n", " cell.text = cell.text.replace(\"MT1\", str(MT1))\n", " if \"B1\" in cell.text:\n", " cell.text = cell.text.replace(\"B1\", str(B1))\n", " if \"S1\" in cell.text:\n", " cell.text = cell.text.replace(\"S1\", str(S1))\n", " if \"M1\" in cell.text:\n", " cell.text = cell.text.replace(\"M1\", str(M1))\n", " if \"MAU1\" in cell.text:\n", " cell.text = cell.text.replace(\"MAU1\", str(MAU1))\n", " if \"NG\" in cell.text:\n", " cell.text = cell.text.replace(\"NG\", str(moda[0]))\n", " cell.text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER \n", " cell.text_frame.vertical_anchor = MSO_VERTICAL_ANCHOR.MIDDLE\n", "caminho_salvar = 'Apresentação Comportamentos2.pptx'\n", "presentation.save(caminho_salvar)\n", "\n", "print(f\"Arquivo PowerPoint atualizado salvo em: {caminho_salvar}\")" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 2 }