Skip to content

Commit

Permalink
Merge pull request #5 from Himanshi-m/main
Browse files Browse the repository at this point in the history
Added csv bulk result feature
  • Loading branch information
cro2003 authored Oct 2, 2024
2 parents dea1c12 + b3c0af9 commit b746d7e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions rgpvApi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .info_api import info
from .result_api import result
from .result_api import csvresults
69 changes: 69 additions & 0 deletions rgpvApi/result_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
import time
import csv
import json
import requests
import pytesseract
Expand Down Expand Up @@ -221,3 +222,71 @@ def __captchaSolver(self, link):
self.__captchaSolver(link)
else:
return text

def csvresults(input_csv , result_type : str, courseId : int, sem : int):
"""This Function Fetches the selected Examination Result in bulk.
Args:
input_csv (str) : path to the csv file with one column titled "enrolment_id"
result_type (str) : "main" or "revaluation" or "challenge"
sem (int): Semester for which Examination Result needed
:Returns:
json: Returns the Examination Result in following format
{"enrollId":
{
(if challenge say)
"enrollId": ENROLLMENT_NUMBER,
"name": NAME_OF_STUDENT,
"subjects": [{
"subjectCode": SUBJECT_CODE,
"subjectName": SUBJECT_NAME,
"status": PASSING_STATUS_(NO_CHANGE/CHANGE),
"newGrade": NEW_GRADE_(IF_CHANGE)
}, {
"subjectCode": SUBJECT_CODE,
"subjectName": SUBJECT_NAME,
"status": PASSING_STATUS_(NO_CHANGE/CHANGE),
"newGrade": NEW_GRADE_(IF_CHANGE)
}]
},
"enrollId":
{
(if main say)
"enrollId": ENROLLMENT_NUMBER,
"name": NAME_OF_STUDENT,
"status": STATUS_OF_RESULT_(PASS/FAIL/PASS_WITH_GRACE),
"sgpa": SGPA,
"cgpa": CGPA,
"resType": RESULT_TYPE(REGULAR/EX),
"subjects": [{
"subject": "CS304- [T]",
"grade": "B"
}, {
"subject": "CS304- [P]",
"grade": "B+"
}]
}
}
"""
results={}
with open(input_csv, mode='r') as file:
reader =csv.DictReader(file)
for row in reader:
enrolment_id=row.get('enrolment_id')
if enrolment_id:
stu_result = result(enrolment_id, courseId)

if result_type == 'main':
fetched_result = stu_result.getMain(sem)
elif result_type == 'revaluation':
fetched_result = stu_result.getReval(sem)
elif result_type == 'challenge':
fetched_result = stu_result.getChlng(sem)
else:
raise ValueError("Invalid result_type. Choose from 'main', 'revaluation', or 'challenge'.")
fetched_result = json.loads(fetched_result)
results[enrolment_id] = fetched_result
return json.dumps(results)

0 comments on commit b746d7e

Please sign in to comment.