Commit bdc5743a authored by 高雅喆's avatar 高雅喆

gray stat data to file

parent 0496a874
from utils import con_sql,tuple2dict,get_yesterday_date
import sys
sys.path.append('..')
from recommended_indexs.utils import con_sql,get_yesterday_date
OUTPUT_PATH = "/data2/models/eda/gray_stat/"
class GrayStat(object):
def __init__(self, cid_type, uid_type, platform,ndays=get_yesterday_date()):
......@@ -60,6 +63,7 @@ if __name__ == '__main__':
# 灰度:_6
# 非灰度:_8
result1 = []
#1.1获取ios和android平台的数据
platforms = ['ios','android']
grays = ['6','8']
for platform in platforms:
......@@ -76,6 +80,7 @@ if __name__ == '__main__':
result1[-1][5]+result1[-2][5],\
result1[-1][6]+result1[-2][6],\
round((result1[-1][5]+result1[-2][5])/(result1[-1][6]+result1[-2][6]),4)])
#1.2获取所有平台的数据
labels = ['6','8','all']
for i in range(3):
result1.append([g_class.ndays,g_class.cid_type,'all',labels[i],\
......@@ -83,8 +88,13 @@ if __name__ == '__main__':
result1[i][5]+result1[i+3][5],\
result1[i][6]+result1[i+3][6],\
round((result1[i][5]+result1[i+3][5])/(result1[i][6]+result1[i+3][6]),4)])
#1.3把一天所有的数据存入文件
output1 = OUTPUT_PATH + "gray_ffm.csv"
with open(output1,'a+') as f:
for line in result1:
line = [str(i) for i in line]
str_line = ','.join(line) + ',' + '\n'
f.write(str_line)
#2.实际中的灰度非灰度:
# ios:
......@@ -94,6 +104,7 @@ if __name__ == '__main__':
# 灰度:0|1|2|6|8
#非灰度:^01268
result2 = []
#2.1获取ios和android平台的数据
platforms = ['ios','android']
for platform in platforms:
#TODO 对于(安卓灰度放到 0 1 2 6 8;iOS灰度保持 6 8)问题,做一个id判断即可
......@@ -114,6 +125,7 @@ if __name__ == '__main__':
result2[-1][5]+result2[-2][5],\
result2[-1][6]+result2[-2][6],\
round((result2[-1][5]+result2[-2][5])/(result2[-1][6]+result2[-2][6]),4)])
#2.2获取所有平台的数据
labels = ['gray','not gray','all']
for i in range(3):
result2.append([g_class.ndays,g_class.cid_type,'all',labels[i],\
......@@ -121,8 +133,14 @@ if __name__ == '__main__':
result2[i][5]+result2[i+3][5],\
result2[i][6]+result2[i+3][6],\
round((result2[i][5]+result2[i+3][5])/(result2[i][6]+result2[i+3][6]),4)])
#2.3把一天所有的数据写入文件
output2 = OUTPUT_PATH + "gray_all.csv"
with open(output2,'a+') as f:
for line in result2:
line = [str(i) for i in line]
str_line = ','.join(line) + ',' + '\n'
f.write(str_line)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment