Dannyar608 commited on
Commit
50c2347
·
verified ·
1 Parent(s): 929de97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -30
app.py CHANGED
@@ -341,19 +341,30 @@ class TranscriptParser:
341
  text, re.DOTALL
342
  )
343
 
 
344
  if student_match:
345
- self.student_data = {
346
- "id": student_match.group(1),
347
- "name": student_match.group(2).replace(",", ", "),
348
- "current_grade": student_match.group(3),
349
- "graduation_year": student_match.group(4),
350
- "unweighted_gpa": float(student_match.group(5)),
351
- "weighted_gpa": float(student_match.group(6)),
352
- "total_credits": float(student_match.group(7)),
353
- "community_service_hours": int(student_match.group(8))
354
- }
 
 
 
 
 
 
 
 
 
355
 
356
  # Extract requirements with better table parsing
 
357
  req_section = re.search(
358
  r"Code\s*Description\s*Required\s*Waived\s*Completed\s*Status(.*?)Total\s*[\d.]+\s*[\d.]+\s*[\d.]+\s*[\d.]+%",
359
  text, re.DOTALL
@@ -366,16 +377,21 @@ class TranscriptParser:
366
  )
367
 
368
  for match in req_matches:
369
- req_code = match.group(1).strip()
370
- self.requirements[req_code] = {
371
- "description": match.group(2).strip(),
372
- "required": float(match.group(3)),
373
- "waived": float(match.group(4)),
374
- "completed": float(match.group(5)),
375
- "status": f"{match.group(6)}%"
376
- }
 
 
 
 
377
 
378
  # Extract course history with more flexible parsing
 
379
  course_section = re.search(
380
  r"Requirement\s*School Year\s*GradeLv1\s*CrsNu m\s*Description(.*?)(?=Legend for Incl:|$)",
381
  text, re.DOTALL
@@ -388,18 +404,22 @@ class TranscriptParser:
388
  )
389
 
390
  for match in course_matches:
391
- self.course_history.append({
392
- "requirement_category": match.group(1).strip(),
393
- "school_year": match.group(2),
394
- "grade_level": match.group(3),
395
- "course_code": match.group(4),
396
- "description": match.group(5).strip(),
397
- "term": match.group(6),
398
- "district_number": match.group(7),
399
- "grade": match.group(8),
400
- "inclusion_status": match.group(9),
401
- "credits": match.group(10)
402
- })
 
 
 
 
403
 
404
  # Identify current courses
405
  self._extract_current_courses()
 
341
  text, re.DOTALL
342
  )
343
 
344
+ self.student_data = {}
345
  if student_match:
346
+ try:
347
+ self.student_data = {
348
+ "id": student_match.group(1),
349
+ "name": student_match.group(2).replace(",", ", "),
350
+ "current_grade": student_match.group(3),
351
+ "graduation_year": student_match.group(4),
352
+ "unweighted_gpa": float(student_match.group(5)),
353
+ "weighted_gpa": float(student_match.group(6)),
354
+ "total_credits": float(student_match.group(7)),
355
+ "community_service_hours": int(student_match.group(8))
356
+ }
357
+ except (IndexError, AttributeError) as e:
358
+ logging.warning(f"Error extracting student info: {str(e)}")
359
+ # Try to get at least the name and ID
360
+ if student_match.group(1) and student_match.group(2):
361
+ self.student_data = {
362
+ "id": student_match.group(1),
363
+ "name": student_match.group(2).replace(",", ", ")
364
+ }
365
 
366
  # Extract requirements with better table parsing
367
+ self.requirements = {}
368
  req_section = re.search(
369
  r"Code\s*Description\s*Required\s*Waived\s*Completed\s*Status(.*?)Total\s*[\d.]+\s*[\d.]+\s*[\d.]+\s*[\d.]+%",
370
  text, re.DOTALL
 
377
  )
378
 
379
  for match in req_matches:
380
+ try:
381
+ req_code = match.group(1).strip()
382
+ self.requirements[req_code] = {
383
+ "description": match.group(2).strip(),
384
+ "required": float(match.group(3)),
385
+ "waived": float(match.group(4)),
386
+ "completed": float(match.group(5)),
387
+ "status": f"{match.group(6)}%"
388
+ }
389
+ except (IndexError, AttributeError) as e:
390
+ logging.warning(f"Skipping requirement due to error: {str(e)}")
391
+ continue
392
 
393
  # Extract course history with more flexible parsing
394
+ self.course_history = []
395
  course_section = re.search(
396
  r"Requirement\s*School Year\s*GradeLv1\s*CrsNu m\s*Description(.*?)(?=Legend for Incl:|$)",
397
  text, re.DOTALL
 
404
  )
405
 
406
  for match in course_matches:
407
+ try:
408
+ self.course_history.append({
409
+ "requirement_category": match.group(1).strip(),
410
+ "school_year": match.group(2),
411
+ "grade_level": match.group(3),
412
+ "course_code": match.group(4),
413
+ "description": match.group(5).strip(),
414
+ "term": match.group(6),
415
+ "district_number": match.group(7),
416
+ "grade": match.group(8),
417
+ "inclusion_status": match.group(9),
418
+ "credits": match.group(10)
419
+ })
420
+ except (IndexError, AttributeError) as e:
421
+ logging.warning(f"Skipping course due to error: {str(e)}")
422
+ continue
423
 
424
  # Identify current courses
425
  self._extract_current_courses()