-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUtil.py
More file actions
67 lines (41 loc) · 1.35 KB
/
Util.py
File metadata and controls
67 lines (41 loc) · 1.35 KB
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
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 20:39:56 2018
@author: Tai
"""
from openpyxl import load_workbook
from openpyxl import Workbook
from datetime import datetime
class ReadExcel(object):
def __init__(self, file_name, sheet_name):
self.wb = load_workbook(file_name)
self.sh = self.wb[sheet_name]
def get_data(self, cell):
return self.sh[cell].value
class WriteExcel(object):
def __init__(self, file_name, sheet_name):
self.wb = Workbook()
self.ws1 = self.wb.active
self.ws1.title = sheet_name
self.filename = file_name
def append_data(self, list):
self.ws1.append(list)
def save(self):
self.wb.save(filename=self.filename)
def logInfo(msg):
timestamp = datetime.now().isoformat()
print(timestamp + " : " + msg)
def main():
logInfo("Hello there!")
f = "C:\\2018\\edureka\\selenium\\INPUT\\gmail_input.xlsx"
sh = ReadExcel(f, 'Sheet1')
print( sh.get_data('A1') )
f1 = "C:\\2018\\edureka\\selenium\\INPUT\\gmail_output.xlsx"
sh = WriteExcel(f1, 'Sheet1')
L = [1, 2, 3, 4, 5]
L1= ['A', 'B', 'C', 'D', 'E']
sh.append_data(L)
sh.append_data(L1)
sh.save()
if __name__ == '__main__':
main()