-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_excels.py
71 lines (53 loc) · 1.35 KB
/
read_excels.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
import xlrd
import xlwt
from xlutils.copy import copy
from xlwt import Workbook
from xlrd import open_workbook
rb = open_workbook('waves.xls')
mysheet = rb.sheet_by_index(0)
numrows = mysheet.nrows
numcols = mysheet.ncols
wb = copy(rb)
w_sheet = wb.get_sheet(0)
st = xlwt.easyxf('pattern: pattern solid;')
st.pattern.pattern_fore_colour = 4
rows = 2
cnt = 0
while(rows < 1050):
val = (str(mysheet.cell_value(rows,0))).encode('ascii')
if(len(val) == 0):
break
val = abs((float(val)))
sta = max(rows-30,2)
en = min(rows+30,1049)
print(sta,rows,en)
fl = 1
for i in range(sta,en):
val_t = abs((float((str(mysheet.cell_value(i,0))).encode('ascii'))))
if(val_t > val):
fl = 0
if(fl == 1):
w_sheet.write(rows,0,mysheet.cell_value(rows,0),st)
cnt = cnt + 1
rows = rows + 1
rows = 2
while(rows < 1050):
val = (str(mysheet.cell_value(rows,1))).encode('ascii')
if(len(val) == 0):
break
val = abs((float(val)))
sta = max(rows-30,2)
en = min(rows+30,1049)
print(sta,rows,en)
fl = 1
for i in range(sta,en):
val_t = abs((float((str(mysheet.cell_value(i,1))).encode('ascii'))))
if(val_t > val):
fl = 0
if(fl == 1):
w_sheet.write(rows,1,mysheet.cell_value(rows,1),st)
cnt = cnt + 1
rows = rows + 1
print(cnt)
wb.save('final.xls')
# https://docs.google.com/forms/d/e/1FAIpQLScqXrVopU6t63GdRQI9LpaWfzDHiNaIJGbazhSRj-0WPT3cVQ/formResponse