AI prompt
This commit is contained in:
@@ -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:
|
I need to analyze CSV files containing school scheduling data and create a complete Python database system. Here's what I need:
|
||||||
|
|
||||||
## **PROJECT OVERVIEW**
|
## **PROJECT OVERVIEW**
|
||||||
|
|||||||
Binary file not shown.
@@ -892,6 +892,14 @@ class SchoolScheduleDB:
|
|||||||
# Check if it looks like a name with multiple capitalized words (Russian or English)
|
# 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
|
# Teacher names typically have 2-4 words with capitalized first letters
|
||||||
words = text.split()
|
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:
|
if len(words) < 2 or len(words) > 4:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -957,6 +965,7 @@ class SchoolScheduleDB:
|
|||||||
def update_teachers_from_cheat_sheet(self, teachers_csv_path):
|
def update_teachers_from_cheat_sheet(self, teachers_csv_path):
|
||||||
"""Update the teachers table from the Teachers.csv file"""
|
"""Update the teachers table from the Teachers.csv file"""
|
||||||
import csv
|
import csv
|
||||||
|
import re
|
||||||
|
|
||||||
with open(teachers_csv_path, 'r', encoding='utf-8') as file:
|
with open(teachers_csv_path, 'r', encoding='utf-8') as file:
|
||||||
reader = csv.reader(file)
|
reader = csv.reader(file)
|
||||||
@@ -966,23 +975,51 @@ class SchoolScheduleDB:
|
|||||||
unique_teachers = set()
|
unique_teachers = set()
|
||||||
|
|
||||||
# Process the CSV to extract teacher names
|
# 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 row in rows:
|
||||||
for cell in row:
|
for cell in row:
|
||||||
cell = cell.strip()
|
cell_str = str(cell).strip()
|
||||||
# Check if the cell looks like a teacher name (Russian/English name format)
|
if '/' in cell_str:
|
||||||
if self._is_likely_teacher_name_enhanced(cell):
|
parts = [part.strip() for part in cell_str.split('/')]
|
||||||
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('/')]
|
|
||||||
for part in parts:
|
for part in parts:
|
||||||
|
part = part.strip()
|
||||||
if self._is_likely_teacher_name_enhanced(part):
|
if self._is_likely_teacher_name_enhanced(part):
|
||||||
unique_teachers.add(part)
|
unique_teachers.add(part)
|
||||||
|
|
||||||
# Insert unique teachers into the database
|
# Insert unique teachers into the database
|
||||||
for teacher_name in unique_teachers:
|
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(
|
self.cursor.execute(
|
||||||
"INSERT OR IGNORE INTO teachers (name, email, phone) VALUES (?, NULL, NULL)",
|
"INSERT OR IGNORE INTO teachers (name, email, phone) VALUES (?, NULL, NULL)",
|
||||||
(teacher_name,)
|
(teacher_name,)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user