Commit 37c1b366 authored by 张彦钊's avatar 张彦钊

add ctr56 file

parent 12169e80
...@@ -6,10 +6,6 @@ import pandas as pd ...@@ -6,10 +6,6 @@ import pandas as pd
DIRECTORY_PATH="/data2/ffm/" DIRECTORY_PATH="/data2/ffm/"
def get_yesterday_date(): def get_yesterday_date():
#自动获取昨天的日期,如"2018-08-08"
"""
:rtype : str
"""
today = datetime.date.today() today = datetime.date.today()
yesterday = today - datetime.timedelta(days=1) yesterday = today - datetime.timedelta(days=1)
yesterday = yesterday.strftime("%Y-%m-%d") yesterday = yesterday.strftime("%Y-%m-%d")
...@@ -29,7 +25,7 @@ def get_data(): ...@@ -29,7 +25,7 @@ def get_data():
return device_id return device_id
def ctr(date): def ctr():
device_id = get_data() device_id = get_data()
sql_click = "select count(cid) from data_feed_click " \ sql_click = "select count(cid) from data_feed_click " \
"where (cid_type = 'diary' or cid_type = 'diary_video') " \ "where (cid_type = 'diary' or cid_type = 'diary_video') " \
...@@ -53,10 +49,10 @@ def ctr(date): ...@@ -53,10 +49,10 @@ def ctr(date):
def rate2file(): def rate2file():
output_path = DIRECTORY_PATH + "56tail.csv" output_path = DIRECTORY_PATH + "56tail.csv"
with open(output_path,'a+') as f: with open(output_path,'a+') as f:
line = get_yesterday_date().replace('-', '')+','+str(temp_data[0])+','+str(temp_data[1])+','+str(temp_data[2])+'\n' line = date.replace('-', '')+','+str(temp_data[0])+','+str(temp_data[1])+','+str(temp_data[2])+'\n'
f.write(line) f.write(line)
if __name__ == "__main__": if __name__ == "__main__":
date = get_yesterday_date date = get_yesterday_date()
temp_data = ctr(date) temp_data = ctr()
rate2file() rate2file()
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