Skip to content

Commit 4e05a60

Browse files
author
lwhhhh
committed
可以统计时间
1 parent 1b8f13f commit 4e05a60

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

lwh/20/CallInfo.xls

23.5 KB
Binary file not shown.

lwh/20/callinfo.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import xlrd
2+
import xlwt
3+
4+
5+
class Statistics(object):
6+
7+
def __init__(self, user):
8+
self.path_read = '/home/lwh/SublimeTextProject/CallInfo.xls'
9+
self.path_save = '/home/lwh/SublimeTextProject/CallInfo(1).xls'
10+
self.user = user
11+
self.work()
12+
13+
# change all format of time to second
14+
def tran_time(self, time_str):
15+
time = time_str.replace('分','.').replace('秒','')
16+
temp = time.split('.')
17+
if len(temp) == 1: # just second
18+
time = int(temp[0])
19+
#print(time)
20+
elif len(temp) == 2: # minute and second
21+
m = int(temp[0]) * 60
22+
s = int(temp[1])
23+
time = m + s
24+
#print(time)
25+
return time
26+
27+
28+
def work(self):
29+
wb = xlrd.open_workbook(self.path_read)
30+
sheets_list = wb.sheet_names()
31+
for sheet_name in sheets_list:
32+
wb_sheet = wb.sheet_by_name(sheet_name)
33+
# print(wb_sheet)
34+
# print(wb_sheet.nrows)
35+
# print(wb_sheet.ncols)
36+
# print(wb_sheet.cell_value(3,8))
37+
for i in range(1, wb_sheet.nrows):
38+
row = wb_sheet.row(i)
39+
time_str = row[3].value
40+
time = self.tran_time(time_str)
41+
self.user.total_time += time
42+
# print(each_time)
43+
# self.user.total_time = row[]
44+
print(self.user.total_time)
45+
46+
class User():
47+
48+
def __init__(self, name, num):
49+
self.name = name
50+
self.num = num
51+
self.total_time = 0
52+
self.most_call_out = ''
53+
self.most_call_in = ''
54+
self.number_in_dict = ''
55+
self.number_out_dict = ''
56+
57+
58+
if __name__ == '__main__':
59+
user0 = User('lwh', '13257584928')
60+
analyzer_obj0 = Statistics(user0)
61+
print('success.')
62+

lwh/20/callinfo.py~

Whitespace-only changes.

0 commit comments

Comments
 (0)