分析同事在线答疑的数据,考评模型还未最终给出:
import time import sys import optparse #操作代码和同事名对应的文件 opfile = 'op_name.txt' #定义问题总数 list_count_sum = 0; evaluation = '十分满意' limit_time = 120 name_dict = {} name_list = [] limit_list = [] #将操作代码和名字加入字典 fg = open(opfile) for name in fg.readlines(): name = name.split(':') name_dict[name[0]] = name[1].strip('\n') name_list.append([name[0],0,0,0]) limit_list.append([name[0]]) #print (name_list) fg.close def get_element(name): for i_element in name_list: if i_element[0] == name: #print (i_element) return i_element[1],i_element[2] #用optparse模板构造-f的类UNIX参数传递 parser = optparse.OptionParser() parser.add_option('-f', '--file', dest='file', help='Path to txt file', default='-') opts, args = parser.parse_args() #读到相关数据并进行统计 fh = open(opts.file) for line in fh.readlines(): list_count_sum += 1 str = line.split('\t') start = time.strptime(str[2], "%Y/%m/%d %H:%M" ) end = time.strptime(str[3], "%Y/%m/%d %H:%M" ) op_time = (time.mktime(end) - time.mktime(start))/60 #print (op_time,"分钟") #if evaluation in str[4].strip('\n'): # for i_element in name_list: # if i_element[0] == str[1]: # i_element[1] += 1 #print ("操作同事:" + name_dict[str[1]]) for i_element in name_list: if i_element[0] == str[1]: if evaluation in str[4].strip('\n'): i_element[1] += 1 if op_time > limit_time: i_element[3] += 1 i_element[2] += 1 if op_time > limit_time: for i_problem in limit_list: if i_problem[0] == str[1]: i_problem.append(str[0]) fh.close() for i_element in name_list: print ('姓名\t','满意\t','总数\t','超时\t') print (name_dict[i_element[0]],'\t',i_element[1],'\t',i_element[2],'\t',i_element[3]) print ('总问题数:',list_count_sum) for i_problem in limit_list: print(i_problem[0]) for n in i_problem: print(n) #print(name_data_sn3)
import time import sys import optparse #操作代码和同事名对应的文件 opfile = 'op_name.txt' #定义问题总数 list_count_sum = 0; evaluation = '十分满意' limit_time = 120 name_dict = {} name_list = [] limit_list = [] #将操作代码和名字加入字典 fg = open(opfile) for name in fg.readlines(): name = name.split(':') name_dict[name[0]] = name[1].strip('\n') name_list.append([name[0],0,0,0]) limit_list.append([name[0]]) #print (name_list) fg.close def get_element(name): for i_element in name_list: if i_element[0] == name: #print (i_element) return i_element[1],i_element[2] #用optparse模板构造-f的类UNIX参数传递 parser = optparse.OptionParser() parser.add_option('-f', '--file', dest='file', help='Path to txt file', default='-') opts, args = parser.parse_args() #读到相关数据并进行统计 fh = open(opts.file) for line in fh.readlines(): list_count_sum += 1 str = line.split('\t') start = time.strptime(str[2], "%Y/%m/%d %H:%M" ) end = time.strptime(str[3], "%Y/%m/%d %H:%M" ) op_time = (time.mktime(end) - time.mktime(start))/60 #print (op_time,"分钟") #if evaluation in str[4].strip('\n'): # for i_element in name_list: # if i_element[0] == str[1]: # i_element[1] += 1 #print ("操作同事:" + name_dict[str[1]]) for i_element in name_list: if i_element[0] == str[1]: if evaluation in str[4].strip('\n'): i_element[1] += 1 if op_time > limit_time: i_element[3] += 1 i_element[2] += 1 if op_time > limit_time: for i_problem in limit_list: if i_problem[0] == str[1]: i_problem.append(str[0]) fh.close() for i_element in name_list: print ('姓名\t','满意\t','总数\t','超时\t') print (name_dict[i_element[0]],'\t',i_element[1],'\t',i_element[2],'\t',i_element[3]) print ('总问题数:',list_count_sum) for i_problem in limit_list: print(i_problem[0]) for n in i_problem: print(n) #print(name_data_sn3)