input file validator
This commit is contained in:
2 files changed
+23
No files matched your search
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3.11
|
||||||
|
from app.util.globals import Error
|
||||||
|
|
||||||
|
def validateInputData(inputFileDir: str) -> Error:
|
||||||
|
with open(inputFileDir, newline='') as csvfile:
|
||||||
|
includes = ['Pupil #', 'CrsNo', 'Description', 'Alternate?']
|
||||||
|
data = csvfile.readline().replace('\n', '').split(',')
|
||||||
|
missing = [e for e in includes if e not in data]
|
||||||
|
if len(missing) > 0:
|
||||||
|
description = 'You are missing the following: '
|
||||||
|
for i in range(len(missing)):
|
||||||
|
if i != len(missing) - 1: description += f'{missing[i]}, '
|
||||||
|
else: description += f'{missing[i]}'
|
||||||
|
missingErr = Error('Missing Required Fields', description)
|
||||||
|
|
||||||
|
return missingErr
|
||||||
|
|
||||||
|
return None
|
||||||
@@ -9,6 +9,7 @@ from app.util.globals import Error
|
|||||||
from app.util.courses import getCourses, writeCoursesToCSV
|
from app.util.courses import getCourses, writeCoursesToCSV
|
||||||
from app.util.students import getStudents, writeStudentsToCSV
|
from app.util.students import getStudents, writeStudentsToCSV
|
||||||
from app.util.errorCalculator import writeErrorsToCSV
|
from app.util.errorCalculator import writeErrorsToCSV
|
||||||
|
from app.util.validator import validateInputData
|
||||||
|
|
||||||
eel.init('template')
|
eel.init('template')
|
||||||
|
|
||||||
@@ -49,6 +50,10 @@ def start(
|
|||||||
block_class_limit = int(block_class_limit)
|
block_class_limit = int(block_class_limit)
|
||||||
total_blocks = int(total_blocks)
|
total_blocks = int(total_blocks)
|
||||||
|
|
||||||
|
eel.post_data('Validating input file...')
|
||||||
|
validateErr = validateInputData(raw_data_dir)
|
||||||
|
if validateErr is not None: return validateErr.__dict__
|
||||||
|
|
||||||
# call pre-algorithm functions read raw data into a processable format
|
# call pre-algorithm functions read raw data into a processable format
|
||||||
eel.post_data('Collecting student information...')
|
eel.post_data('Collecting student information...')
|
||||||
students = getStudents(
|
students = getStudents(
|
||||||
|
|||||||
Reference in new issue
Block a user