-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExcelTimetablePython
More file actions
47 lines (32 loc) · 1.06 KB
/
ExcelTimetablePython
File metadata and controls
47 lines (32 loc) · 1.06 KB
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
import time, string
digits = string.digits
week_days = ['MON', 'TUE', 'WED', 'THU', 'FRI']
timetable = open('timetable.csv', 'r')
def find_classes(t, digits):
#find all the different classes in the timetable (eg. 1A, 2A ...)
all_classes = []
# print('Classes\n', t.read())
for line in t:
line = list(line)
for i in range(len(line)):
if line[i] == 'A' and line[i-1] in digits:
current_class = line[i-1]+line[i]
if current_class not in all_classes:
all_classes.append(current_class)
t.seek(0)
return all_classes
def find_days(t, week_days):
#find all the days in the timetable (eg. MON, TUE ...)
# print('Days\n', t.read())
all_days = []
for line in t:
for day in week_days:
if day in line and day not in all_days:
all_days.append(day)
t.seek(0)
return all_days
days = find_days(timetable, week_days)
classes = find_classes(timetable, digits)
print(days)
print(classes)
timetable.close()