-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
134 lines (110 loc) · 3.78 KB
/
main.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# from xlwt import *
# from xlrd import *
# from xlutils.copy import *
from openpyxl import *
import time
# workbook = xlrd.open_workbook('Book1.xls')
# sheet = workbook.sheet_by_index(0)
# data = [sheet.cell_value(0, col) for col in range(sheet.ncols)]
#
# workbook = xlwt.Workbook()
# sheet = workbook.add_sheet('test')
#
# for index, value in enumerate(data):
# sheet.write(0, index, value)
#
# workbook.save('output.xls')
with open('tabs.txt', 'r') as f:
LoL = [x.strip().split('\t') for x in f]
# print (LoL)
# AStuff = {'FC4', 'FD'}
wb = load_workbook(filename='outFile.xlsx')
# ws = wb.get_sheet_by_name('Birds details')
sheet_ranges = wb['Birds details']
sheet2_ranges = wb['Feed']
# print(sheet_ranges.cell(row=4, column=3).value)
that = 159
now = that
touchdown = 1
dateSave = LoL[13][2]
reasonsMed = LoL[13][0]
remarks = LoL[13][1]
for i in range(4, 44):
# print(str(sheet_ranges.cell(row=i, column=1).value)[:10] + " " + dateSave[6:10]+"-"+dateSave[3:5]+"-"+dateSave[0:2])
if str(sheet_ranges.cell(row=i, column=1).value)[:10] == dateSave[6:10]+"-"+dateSave[3:5]+"-"+dateSave[0:2]:
touchdown = i
# print(touchdown)
break
ind = 3
# first identify row, then this
for i in range(1, 13):
for j in range(now, now + 12):
# print str(int(LoL[i][j-now])) + " " + str(touchdown) + " " + str(j)
sheet_ranges.cell(row=touchdown, column=j).value = int(LoL[i][j - now])
sheet2_ranges.cell(row=touchdown, column=ind + j - now).value = float(LoL[i + 13][j-now])
now = now + 12 + 1
ind += 13
# that = now + 12
sheet_ranges.cell(row=touchdown, column=471).value = reasonsMed[0:-1]
sheet_ranges.cell(row=touchdown, column=472).value = remarks[0:-1]
sheet_ranges.cell(row=touchdown, column=473).value = str(time.strftime("%d-%B-%y | %H:%M:%S"))
sheet_ranges.cell(row=touchdown, column=1).value = LoL[13][2]
wb.save('newDetails.xlsx')
# wb = load_workbook(filename='outFile.xlsx')
# sheet2_ranges = wb['Feed']
# that = 159
# now = that
# for i in range(1, 13):
# for j in range(now, now + 12):
# # print str(int(LoL[i][j-now])) + " " + str(touchdown) + " " + str(j)
# # sheet_ranges.cell(row=touchdown, column=j).value = int(LoL[i][j - now])
# sheet2_ranges.cell(row=touchdown, column=ind + j - now).value = float(LoL[i + 13][j-now])
# now = now + 12 + 1
# ind += 13
#
# at 473, put cdx-wala date
#
# print wb.get_sheet_names()
# print ws['F1']
# f.close()
#
# readBook = open_workbook('Book1.xls')
# readSheet = readBook.sheet_by_index(0)
# x = int(LoL[0][0])
# data = readSheet.cell_value(0, 0)
# rb = open_workbook('outFile.xlsx', formatting_info=True)
# rb = open_workbook('outFile.xlsx')
# r_sheet = rb.sheet_by_index(3) # read only copy to introspect the file
# wb = copy(rb) # a writable copy (I can't read values out of this, only write to it)
#
# w_sheet = wb.get_sheet(3) # the sheet to write to within the writable copy
# x = 3
# m = r_sheet.cell_value(x, 1)
# if int(m) == 3:
# w_sheet.write(x, ord('s')-ord('a'), "colombo")
# x = 4
# if int(r_sheet.cell_value(x, 1)) == 3:
# w_sheet.write(x, ord('s')-ord('a'), "colombo")
# x = 5
# if int(r_sheet.cell_value(x, 1)) == 3:
# w_sheet.write(x, ord('s')-ord('a'), "colombo")
# x = 6
# if int(r_sheet.cell_value(x, 1)) == 3:
# w_sheet.write(x, ord('s')-ord('a'), "colombo")
#
# x = 1
# print r_sheet.cell_value(x, 1)
# x = 2
# print r_sheet.cell_value(x, 1)
# x = 3
# print r_sheet.cell_value(x, 1)
# x = 4
# print r_sheet.cell_value(x, 1)
# x = 5
# print r_sheet.cell_value(x, 1)
# x = 6
# print r_sheet.cell_value(x, 1)
# w_sheet.write(1, 3, "kozhakattai")
# w_sheet.write(13, 13, "kadubu")
# wb.save('outFile.xlsx')
# print data