Fix PDF extraction patterns and improve robustness

- Replace lambda functions with named mapping functions (map_pattern_1-10)
- Add Pattern 10 for Gender+School+LastName+Grade+FirstName format
- Fix pattern matching logic to properly update extracted data
- Achieve 100% success rate on 9 test PDF formats
- Add comprehensive regex patterns for diverse concatenation formats
- Improve error handling and logging for failed extractions
This commit is contained in:
nmemmert committed 2025-11-06 12:32:18 -05:00
1 parent a5b26d1324
commit 5fb1a855a1
2 files changed
+641 -159

No files matched your search

+9 -7
View File
@@ -8,7 +8,7 @@ A Python web application built with Flask that automatically renames PDF files b
- **Batch Processing**: Handle multiple PDFs or ZIP archives containing PDFs
- **Form Field Extraction**: Uses PyPDF2 to read PDF form fields
- **Intelligent Renaming**: Renames files to "LastName_FirstName.pdf" format
- **Structured Organization**: Creates Episode/School/Grade folder hierarchy
- **Structured Organization**: Creates Episode/School/Grade/Gender folder hierarchy
- **Duplicate Handling**: Automatically appends counters for duplicate names
- **ZIP Support**: Upload ZIP files and download processed results as ZIP with folder structure
- **Job Management**: Background processing with job status tracking and history
@@ -122,12 +122,14 @@ Users can choose their preferred login method on the login page.
## Important Notes
- PDFs must contain fillable form fields named exactly: "Student First Name", "Student Last Name", "Student Grade", and "Student School"
- All four fields must be present and filled for the PDF to be processed
- Files without these fields or with extraction errors will be skipped
- All processing happens server-side with temporary file storage
- Maximum upload size is limited to 500MB
- Output creates a structured folder hierarchy within the downloaded ZIP
- **PDF Compatibility**: The system works with both fillable PDFs (containing form fields) and flattened PDFs (filled forms that have been saved)
- **Required Information**: PDFs must contain student information for: "Student First Name", "Student Last Name", "Student Grade", "Student School", and "Gender"
- **Field Extraction**: For fillable PDFs, looks for form fields with exact names. For flattened PDFs, extracts information from the text content of the first page
- **Processing Requirements**: All five pieces of student information must be present for the PDF to be processed
- **Error Handling**: Files without the required information or with extraction errors will be skipped with detailed error messages
- **Security**: All processing happens server-side with temporary file storage
- **Limits**: Maximum upload size is limited to 500MB
- **Output**: Creates a structured folder hierarchy within the downloaded ZIP (Episode/School/Grade/Gender)
## Production Deployment