diff --git a/ai_prompt.txt b/ai_prompt.txt index 6e178e4..db02397 100644 --- a/ai_prompt.txt +++ b/ai_prompt.txt @@ -1,8 +1,3 @@ -Here's a comprehensive AI prompt that will guide you through the entire process of analyzing CSV data, migrating to a database, and building a Python application to query it: - -## **Complete AI Prompt for CSV to Database Migration & Python App Development** - -```text I need to analyze CSV files containing school scheduling data and create a complete Python database system. Here's what I need: ## **PROJECT OVERVIEW** diff --git a/scheduler_bots/__pycache__/database.cpython-314.pyc b/scheduler_bots/__pycache__/database.cpython-314.pyc index 7b63e43..1f1e1fc 100644 Binary files a/scheduler_bots/__pycache__/database.cpython-314.pyc and b/scheduler_bots/__pycache__/database.cpython-314.pyc differ diff --git a/scheduler_bots/database.py b/scheduler_bots/database.py index 56fffce..24d8b72 100644 --- a/scheduler_bots/database.py +++ b/scheduler_bots/database.py @@ -892,6 +892,14 @@ class SchoolScheduleDB: # Check if it looks like a name with multiple capitalized words (Russian or English) # Teacher names typically have 2-4 words with capitalized first letters words = text.split() + + # Handle compound names like "Name1 / Name2" + if '/' in text: + parts = [part.strip() for part in text.split('/')] + for part in parts: + if self._is_likely_teacher_name_simple(part): + return True + if len(words) < 2 or len(words) > 4: return False @@ -957,6 +965,7 @@ class SchoolScheduleDB: def update_teachers_from_cheat_sheet(self, teachers_csv_path): """Update the teachers table from the Teachers.csv file""" import csv + import re with open(teachers_csv_path, 'r', encoding='utf-8') as file: reader = csv.reader(file) @@ -966,23 +975,51 @@ class SchoolScheduleDB: unique_teachers = set() # Process the CSV to extract teacher names + # Teacher names appear in positions after subjects and before group info + for row in rows: + # Process the row in triplets (subject, teacher, group_info) pattern + j = 0 + while j < len(row) - 2: + # Look for a subject-like cell followed by a teacher-like cell + subject_cell = str(row[j]).strip() if j < len(row) else "" + teacher_cell = str(row[j + 1]).strip() if j + 1 < len(row) else "" + group_cell = str(row[j + 2]).strip() if j + 2 < len(row) else "" + + # Check if middle cell is likely a teacher name (between subject and group) + if (subject_cell and self._is_likely_subject_name_simple(subject_cell) and + teacher_cell and self._is_likely_teacher_name_enhanced(teacher_cell) and + group_cell and self._is_likely_group_identifier(group_cell)): + + # Handle composite teacher names like "Name1 / Name2" + if '/' in teacher_cell: + parts = [part.strip() for part in teacher_cell.split('/')] + for part in parts: + if self._is_likely_teacher_name_enhanced(part): + unique_teachers.add(part) + else: + unique_teachers.add(teacher_cell) + + # Also check if the current cell itself might be a teacher name + current_cell = str(row[j]).strip() + if current_cell and self._is_likely_teacher_name_enhanced(current_cell): + unique_teachers.add(current_cell) + + j += 1 # Move to next cell + + # Special handling for teacher names that appear in combination patterns like "First Last / Other Teacher" for row in rows: for cell in row: - cell = cell.strip() - # Check if the cell looks like a teacher name (Russian/English name format) - if self._is_likely_teacher_name_enhanced(cell): - unique_teachers.add(cell) - - # Also check for names that might be combined with "/" (like "Name1 / Name2") - if '/' in cell: - parts = [part.strip() for part in cell.split('/')] + cell_str = str(cell).strip() + if '/' in cell_str: + parts = [part.strip() for part in cell_str.split('/')] for part in parts: + part = part.strip() if self._is_likely_teacher_name_enhanced(part): unique_teachers.add(part) # Insert unique teachers into the database for teacher_name in unique_teachers: - if teacher_name: # Make sure it's not an empty string + if teacher_name and len(teacher_name) > 2: # Make sure it's not an empty string or very short self.cursor.execute( "INSERT OR IGNORE INTO teachers (name, email, phone) VALUES (?, NULL, NULL)", (teacher_name,) diff --git a/scheduler_bots/school_schedule.db b/scheduler_bots/school_schedule.db index 2d1d507..ae2b547 100644 Binary files a/scheduler_bots/school_schedule.db and b/scheduler_bots/school_schedule.db differ