-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.py
56 lines (35 loc) · 1.13 KB
/
parser.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
import csv
import sys
import copy
def parse():
daydict = {}
resultdict = {}
with open('./data/Monday.csv') as file:
resultdict['Monday'] = copy.deepcopy(processday(file))
with open('./data/Tuesday.csv') as file:
resultdict['Tuesday'] = copy.deepcopy(processday(file))
with open('./data/Wednesday.csv') as file:
resultdict['Wednesday'] = copy.deepcopy(processday(file))
with open('./data/Thursday.csv') as file:
resultdict['Thursday'] = copy.deepcopy(processday(file))
with open('./data/Friday.csv') as file:
resultdict['Friday'] = copy.deepcopy(processday(file))
return resultdict
def processday(file):
daydict = {}
reader = csv.reader(file, delimiter=',')
classrooms = reader.next();
for room in range(1,len(classrooms)):
daydict[classrooms[room]] = {}
for row in reader:
for i in range(len(row)):
if row[i] == '0':
daydict[classrooms[i]][row[0]] = False
elif row[i] == '1':
daydict[classrooms[i]][row[0]] = True
return daydict
def getRoomList():
with open('./data/Monday.csv') as file:
reader = csv.reader(file, delimiter=',')
classrooms = reader.next();
return classrooms[1:-1]