Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
37c1b366
Commit
37c1b366
authored
Oct 12, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ctr56 file
parent
12169e80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
ctr-56.py
ctr-56.py
+4
-8
No files found.
ctr-56.py
View file @
37c1b366
...
@@ -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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment