-
Notifications
You must be signed in to change notification settings - Fork 0
/
readExcel.py
executable file
·102 lines (80 loc) · 2.31 KB
/
readExcel.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
# python -m pip install -U pip setuptools for Windows
# pip install -U pip setuptools For Linux/OS X
#
from openpyxl import Workbook
from openpyxl import load_workbook
import os
import pandas as pd
import sys
# Retrieve current working directory (`cwd`)
cwd = os.getcwd()
#print ("Current working directory: " + cwd)
# Change directory
os.chdir("/home/dima/python/example")
# List all files and directories in current directory
#print("Listing all files in the dir:")
#print(os.listdir('.'))
pathToFile="/to/path/file"
def findAllQuotas(ws, c):
quotas=[]
start_l = c
start_num = "4"
start = start_l + start_num
cell = ws[start]
while not cell.value is None:
quotas.append(cell.value)
start_num = str(int(start_num)+1)
start = start_l + start_num
cell = ws[start]
#for q in ws.iter_rows(min_row=1, max_col=30, max_row=2):
return quotas
def printSemiColonValues(list):
f = open('/home/dima/python/example/log.txt', 'ab')
for value in list:
f.write(value + ";")
#sys.stdout.write(value + ";")
sys.stdout.flush()
### Definitions of array of quotas
wb = load_workbook('example.xlsx')
ws = wb.active
for row in ws.iter_rows(min_row=1, max_col=3, max_row=2):
for cell in row:
print(cell.value)
### print quotas ##########
for q in findAllQuotas(ws, "M"):
sys.stdout.write(q+ " ")
for q1 in findAllQuotas(ws, "N"):
sys.stdout.write(str(q1)+ " ")
###########################
st = list("Hello World")
st[2] = "L"
print("".join(st))
#d = ws.cell(row=4, column=2, value=10)
#print(ws["M5"].value)
#print wb.get_sheet_names()
#wb = open_workbook('example.xlsx')
#for s in wb.sheets():
# values = []
# for row in range(s.nrows):
# col_value = []
# for col in range(s.ncols):
# value = (s.cell(row,col).value)
# try : value = str(int(value))
# except : pass
# col_value.append(value)
# values.append(col_value)
#print values
#for el in values:
# for el1 in el:
# for q in quotas:
# if (el1 == q):
# print ("Found quotas")
# else:
# print("No quotas found")
#printSemiColonValues(values[0])
#print("")
#printSemiColonValues(values[1])
#print(values[0][0])
#print(", ")
#print(values[0][1])
#print(s.nrows)