-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.py
95 lines (82 loc) · 2.12 KB
/
convert.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
# -*- coding: cp1252 -*-
import xlrd
import json
import unicodedata
workbook = xlrd.open_workbook('ambiental.xlsx', encoding_override="cp1252")
s = workbook.sheet_by_index(1)
sala = 'NO SALA'
lista = []
dia = ''
keys = ['fake', 'sem','dis','prof','curso','codTurma','dia', 'hInicio', 'hFim', 'lab', 'comp', 'sala',]
turma = {
'fake': '',
'sem': '',
'dis': '',
'prof': '',
'curso': '',
'codTurma': '',
'dia': '',
'hInicio': '',
'hFim': '',
'lab': '',
'comp': '',
'sala': '',
}
for i in range(6, 55):
lista.append(turma)
turma = {
'fake': '',
'sem': '',
'dis': '',
'prof': '',
'curso': '',
'codTurma': '',
'dia': '',
'hInicio': '',
'hFim': '',
'lab': '',
'comp': '',
'sala': '',
}
dia = ''
for j in range(1, 11):
if type(s.cell(i, j).value) == float:
turma[keys[j]] = s.cell(i, j).value
print 'aqui'
elif (j == 11) and (i > 6):
if s.cell(i, j).value == '':
turma[keys[j]] = sala
elif s.cell(i, j).value == 'Sala':
print('X')
else:
sala = s.cell(i, j).value
turma[keys[j]] = sala
elif s.cell(i, j).value == '':
print('X')
elif s.cell(i, j).value == 'Sem':
print('X')
elif s.cell(i, j).value == 'Disciplinas':
print('X')
elif s.cell(i, j).value == 'Disciplinas':
print('X')
elif s.cell(i, j).value == 'Professor':
print('X')
elif s.cell(i, j).value == 'Curso':
print('X')
elif unicodedata.normalize('NFKD', s.cell(i, j).value).encode('ASCII', 'ignore') == 'Codigo':
print('X')
elif s.cell(i, j).value == 'Dia':
print('X')
elif unicodedata.normalize('NFKD', s.cell(i, j).value).encode('ASCII', 'ignore') == 'Horario Inicial':
print('X')
elif unicodedata.normalize('NFKD', s.cell(i, j).value).encode('ASCII', 'ignore') == 'Horario Final':
print('X')
elif s.cell(i, j).value == 'Lab.':
print('X')
elif s.cell(i, j).value == 'Compartilhada':
print('X')
elif s.cell(i, j).value == 'Sala':
print('X')
else:
turma[keys[j]] = s.cell(i, j).value
print(json.dumps(lista))