{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyNUxlFk8o1sQFzzJ4FoGbc3"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":90},"id":"e-n37xid8sKu","executionInfo":{"status":"ok","timestamp":1766425110902,"user_tz":300,"elapsed":9585,"user":{"displayName":"Natasha Holmes","userId":"01063502562103573622"}},"outputId":"1cc8e6d8-d45d-46ab-fc95-30e81cc159b8"},"outputs":[{"output_type":"display_data","data":{"text/plain":[""],"text/html":["\n"," \n"," \n"," Upload widget is only available when the cell has been executed in the\n"," current browser session. Please rerun this cell to enable.\n"," \n"," "]},"metadata":{}},{"output_type":"stream","name":"stdout","text":["Saving Phys 1110 FA25 Attendance_afterSept29.xlsx to Phys 1110 FA25 Attendance_afterSept29.xlsx\n"]}],"source":["import pandas as pd\n","import re\n","\n","# Upload your Excel file\n","from google.colab import files\n","uploaded = files.upload()\n"]},{"cell_type":"code","source":["###SALT\n","\n","# Replace with the uploaded file name\n","excel_file_path = list(uploaded.keys())[0]\n","\n","# Load the Excel file and get the sheet names\n","xls = pd.ExcelFile(excel_file_path)\n","sheet_names = xls.sheet_names\n","\n","# Filter the first 11 sheets that match the pattern \"SALT-4xx\"\n","salt_sheets = [name for name in sheet_names if re.match(r\"SALT-4\\d{2}\", name)][:11]\n","\n","# Initialize a list to store DataFrames\n","dfs = []\n","\n","# Loop through each selected sheet\n","for sheet in salt_sheets:\n"," # Read the sheet into a DataFrame\n"," df = pd.read_excel(xls, sheet_name=sheet)\n","\n"," # Select columns: 'SIS Login ID' and any column matching 'Lab xx Attendance'\n"," selected_columns = ['SIS Login ID'] + ['Lab Section'] + [col for col in df.columns if 'Attendance' in col]\n","\n"," # Append the filtered DataFrame to the list\n"," dfs.append(df[selected_columns])\n","\n","# Concatenate all DataFrames vertically\n","combined_df = pd.concat(dfs, ignore_index=True)\n","\n","# Save the result to a new CSV file\n","combined_df.to_csv('combined_attendance-salt.csv', index=False)\n","\n","# Download the CSV file\n","files.download('combined_attendance-salt.csv')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":17},"id":"n2dgTZhf-A9T","executionInfo":{"status":"ok","timestamp":1766425117687,"user_tz":300,"elapsed":615,"user":{"displayName":"Natasha Holmes","userId":"01063502562103573622"}},"outputId":"4b632957-b217-403d-b5d9-f4b4cbb1743d"},"execution_count":2,"outputs":[{"output_type":"display_data","data":{"text/plain":[""],"application/javascript":["\n"," async function download(id, filename, size) {\n"," if (!google.colab.kernel.accessAllowed) {\n"," return;\n"," }\n"," const div = document.createElement('div');\n"," const label = document.createElement('label');\n"," label.textContent = `Downloading \"${filename}\": `;\n"," div.appendChild(label);\n"," const progress = document.createElement('progress');\n"," progress.max = size;\n"," div.appendChild(progress);\n"," document.body.appendChild(div);\n","\n"," const buffers = [];\n"," let downloaded = 0;\n","\n"," const channel = await google.colab.kernel.comms.open(id);\n"," // Send a message to notify the kernel that we're ready.\n"," channel.send({})\n","\n"," for await (const message of channel.messages) {\n"," // Send a message to notify the kernel that we're ready.\n"," channel.send({})\n"," if (message.buffers) {\n"," for (const buffer of message.buffers) {\n"," buffers.push(buffer);\n"," downloaded += buffer.byteLength;\n"," progress.value = downloaded;\n"," }\n"," }\n"," }\n"," const blob = new Blob(buffers, {type: 'application/binary'});\n"," const a = document.createElement('a');\n"," a.href = window.URL.createObjectURL(blob);\n"," a.download = filename;\n"," div.appendChild(a);\n"," a.click();\n"," div.remove();\n"," }\n"," "]},"metadata":{}},{"output_type":"display_data","data":{"text/plain":[""],"application/javascript":["download(\"download_e87cf00d-3d18-404d-93fd-01e6a79bf6b7\", \"combined_attendance-salt.csv\", 13583)"]},"metadata":{}}]},{"cell_type":"code","source":["###PEPPER\n","\n","# Replace with the uploaded file name\n","excel_file_path = list(uploaded.keys())[0]\n","\n","# Load the Excel file and get the sheet names\n","xls = pd.ExcelFile(excel_file_path)\n","sheet_names = xls.sheet_names\n","\n","# Filter the first 11 sheets that match the pattern \"PEPPER-4xx\"\n","salt_sheets = [name for name in sheet_names if re.match(r\"PEPPER-4\\d{2}\", name)][:9]\n","\n","# Initialize a list to store DataFrames\n","dfs = []\n","\n","# Loop through each selected sheet\n","for sheet in salt_sheets:\n"," # Read the sheet into a DataFrame\n"," df = pd.read_excel(xls, sheet_name=sheet)\n","\n"," # Select columns: 'SIS Login ID' and any column matching 'Lab xx Attendance'\n"," selected_columns = ['SIS Login ID'] + ['Lab Section'] + [col for col in df.columns if 'Attendance' in col]\n","\n"," # Append the filtered DataFrame to the list\n"," dfs.append(df[selected_columns])\n","\n","# Concatenate all DataFrames vertically\n","combined_df = pd.concat(dfs, ignore_index=True)\n","\n","# Save the result to a new CSV file\n","combined_df.to_csv('combined_attendance-pepper.csv', index=False)\n","\n","# Download the CSV file\n","files.download('combined_attendance-pepper.csv')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":17},"id":"okhXrA9scFrf","executionInfo":{"status":"ok","timestamp":1766414993335,"user_tz":300,"elapsed":169,"user":{"displayName":"Natasha Holmes","userId":"01063502562103573622"}},"outputId":"ee8cc116-477b-43fe-8c75-1534842b3e2e"},"execution_count":3,"outputs":[{"output_type":"display_data","data":{"text/plain":[""],"application/javascript":["\n"," async function download(id, filename, size) {\n"," if (!google.colab.kernel.accessAllowed) {\n"," return;\n"," }\n"," const div = document.createElement('div');\n"," const label = document.createElement('label');\n"," label.textContent = `Downloading \"${filename}\": `;\n"," div.appendChild(label);\n"," const progress = document.createElement('progress');\n"," progress.max = size;\n"," div.appendChild(progress);\n"," document.body.appendChild(div);\n","\n"," const buffers = [];\n"," let downloaded = 0;\n","\n"," const channel = await google.colab.kernel.comms.open(id);\n"," // Send a message to notify the kernel that we're ready.\n"," channel.send({})\n","\n"," for await (const message of channel.messages) {\n"," // Send a message to notify the kernel that we're ready.\n"," channel.send({})\n"," if (message.buffers) {\n"," for (const buffer of message.buffers) {\n"," buffers.push(buffer);\n"," downloaded += buffer.byteLength;\n"," progress.value = downloaded;\n"," }\n"," }\n"," }\n"," const blob = new Blob(buffers, {type: 'application/binary'});\n"," const a = document.createElement('a');\n"," a.href = window.URL.createObjectURL(blob);\n"," a.download = filename;\n"," div.appendChild(a);\n"," a.click();\n"," div.remove();\n"," }\n"," "]},"metadata":{}},{"output_type":"display_data","data":{"text/plain":[""],"application/javascript":["download(\"download_33bfda99-7b7b-457b-8a81-e591e28149da\", \"combined_attendance-pepper.csv\", 13156)"]},"metadata":{}}]},{"cell_type":"code","source":[],"metadata":{"id":"whaKmeUScNZd"},"execution_count":null,"outputs":[]}]}