-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConvertToJson.py
96 lines (84 loc) · 2.61 KB
/
ConvertToJson.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import string
import csv
import json
letters = string.ascii_uppercase
'''
AUTHOR: Shawn Michael A. Sudaria
GITHUB: https://github.com/0xM1cx
STATUS: In Development
DESCRIPTION:
The goal of this file is to parse the data in the csv files
and put them all into a json file to be accessed by the
getStatistics.py file for it to be displayed graphically
'''
def importToJSON(data):
with open("DATA.json", "w") as jsonFILE:
json.dump(data, jsonFILE, indent=8)
def getPassers():
courses_dict = {
'BEED': [],
'BS Ind. Tech. GAP': [],
'BS Ind. Tech. E': [],
'BSF': [],
'BSMATH': [],
'BTVTED HVART': [],
'BSOA': [],
'BTVED AFA': [],
'BSIT': [],
'BSE': [],
'BS Ind. Tech. ELX': [],
'BAEL': [],
'BSID': [],
'BSCE': [],
'BSED SCI': [],
'BS Ind. Tech. CA': [],
'BPED': [],
'BSHM': [],
'BENS': [],
'BSIENG': [],
'BSND': [],
'BTVTED FSM': [],
'BSFi': [],
'BSARCH': [],
'BSMT AT': [],
'BSA': [],
'BSED MATH': [],
'BSEE': [],
'BSM': [],
'BSECON': [],
'BSME': [],
'BSCHE': [],
'BSECE': [],
'BTVTED GFD': [],
'BSAGRI': [],
'BSCHEM': [],
'BCAEd': [],
'BSSTAT': [],
'BTLED HE': [],
'BSE ENGLISH': [],
'BTLED IA': [],
'BSGE': [],
'BSMT MS': [],
'BS Ind. Tech. CC': [],
'BTVED AT': [],
'BTVED CCT': [],
'BS Ind. Tech. RAC': [],
'BTVED ET': [],
'BS Ind. Tech. CFD': [],
'BSMT WF': []
}
# loop through every csv file that are sorted alphabetically
for i in letters:
try:
with open(f"CSV/EVSU-College-Admission-Application-Result-SY-2021-2022-{i}.csv") as file:
reader = csv.reader(file)
for row in reader: # This loops through the rows inside every CSV files
if row[5] != "PROGRAM":
courses_dict[row[5]].append(f"{row[2]}, {row[3]} {row[4]}")
except FileNotFoundError:
print("File Not Found, Skipping...")
JSON_DATA = json.dumps(courses_dict, indent=8)
loaded = json.loads(JSON_DATA)
return loaded
json_DATA = getPassers()
importToJSON(json_DATA)