-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_cache_data.py
executable file
·39 lines (32 loc) · 1.17 KB
/
test_cache_data.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
import cPickle
from openpyxl.reader.excel import load_workbook
class RowData():
def __init__(self, lat, lon, data_list, x=None, y=None):
self.lat = lat
self.lon = lon
self.x = x
self.y = y
self.data = data_list
if __name__ == '__main__':
print 'caching workbook...'
path = "res/grid_marsel-new.xlsx"
cache_path = "res/cache_workbook"
wb = load_workbook(path)
sheet = wb.get_active_sheet()
cache = []
cells_lat = sheet.range('G2:G9802')
cells_lon = sheet.range('F2:F9802')
cells_no2 = sheet.range('B2:B9802')
cells_so2 = sheet.range('C2:C9802')
cellsx = sheet.range('D2:D9802')
cellsy = sheet.range('E2:E9802')
data_len = len(cells_lat)
for i in range(data_len):
row = RowData(cells_lat[i][0].value, cells_lon[i][0].value,
(cells_no2[i][0].value, cells_so2[i][0].value),
cellsx[i][0].value, cellsy[i][0].value)
cache.append(row)
cache_file = open('res/cache_payload', 'w')
cPickle.dump(cache, cache_file)
cache_file.close()
print 'Done!'