Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
meta_base_code
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黎涛
meta_base_code
Commits
f490d04c
Commit
f490d04c
authored
Sep 26, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3d0c15bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
16 deletions
+49
-16
out_put_user_post_each_strategy.py
output/out_put_user_post_each_strategy.py
+49
-16
No files found.
output/out_put_user_post_each_strategy.py
View file @
f490d04c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
import
hashlib
import
hashlib
import
json
import
json
import
pandas
import
pymysql
import
pymysql
import
xlwt
,
datetime
import
xlwt
,
datetime
import
redis
import
redis
...
@@ -263,7 +263,8 @@ exposure_sql = """
...
@@ -263,7 +263,8 @@ exposure_sql = """
SELECT
SELECT
cl_id,
cl_id,
card_id,
card_id,
transaction_type
FROM
FROM
(
(
SELECT
SELECT
...
@@ -327,12 +328,13 @@ for res in sql_res:
...
@@ -327,12 +328,13 @@ for res in sql_res:
if
int
(
card_id
)
in
second_demands_tractate_dict
:
if
int
(
card_id
)
in
second_demands_tractate_dict
:
# print(cl_id, second_demands_tag_dict[card_id])
# print(cl_id, second_demands_tag_dict[card_id])
for
tag_id
in
second_demands_tractate_dict
[
int
(
card_id
)]:
for
tag_id
in
second_demands_tractate_dict
[
int
(
card_id
)]:
if
transaction_type
not
in
second_demands_id_count
:
if
tag_id
in
second_demands_id_count
:
second_demands_id_count
[
transaction_type
]
=
{}
second_demands_id_count
[
tag_id
][
int
(
card_id
)]
=
1
if
tag_id
in
second_demands_id_count
[
transaction_type
]:
second_demands_id_count
[
transaction_type
][
tag_id
][
int
(
card_id
)]
=
1
else
:
else
:
second_demands_id_count
[
tag_id
]
=
{}
second_demands_id_count
[
t
ransaction_type
][
t
ag_id
]
=
{}
second_demands_id_count
[
tag_id
][
int
(
card_id
)]
=
1
second_demands_id_count
[
t
ransaction_type
][
t
ag_id
][
int
(
card_id
)]
=
1
if
tag_id
in
transaction_second_demands_dict
:
if
tag_id
in
transaction_second_demands_dict
:
try
:
try
:
...
@@ -355,11 +357,13 @@ for res in sql_res:
...
@@ -355,11 +357,13 @@ for res in sql_res:
if
int
(
card_id
)
in
tags_v3_tractate_dict
:
if
int
(
card_id
)
in
tags_v3_tractate_dict
:
# print(cl_id,projects_demands_tag_dict[cl_id])
# print(cl_id,projects_demands_tag_dict[cl_id])
for
tag_id
in
tags_v3_tractate_dict
[
int
(
card_id
)]:
for
tag_id
in
tags_v3_tractate_dict
[
int
(
card_id
)]:
if
tag_id
in
projects_demands_id_count
:
if
transaction_type
not
in
tags_v3_tractate_dict
:
projects_demands_id_count
[
tag_id
][
int
(
card_id
)]
=
1
tags_v3_tractate_dict
[
transaction_type
]
=
{}
if
tag_id
in
projects_demands_id_count
[
transaction_type
]:
projects_demands_id_count
[
transaction_type
][
tag_id
][
int
(
card_id
)]
=
1
else
:
else
:
projects_demands_id_count
[
tag_id
]
=
{}
projects_demands_id_count
[
t
ransaction_type
][
t
ag_id
]
=
{}
projects_demands_id_count
[
tag_id
][
int
(
card_id
)]
=
1
projects_demands_id_count
[
t
ransaction_type
][
t
ag_id
][
int
(
card_id
)]
=
1
if
tag_id
in
transaction_projects_demands_type
:
if
tag_id
in
transaction_projects_demands_type
:
try
:
try
:
...
@@ -381,16 +385,27 @@ second_demands_list = []
...
@@ -381,16 +385,27 @@ second_demands_list = []
# time.sleep(10)
# time.sleep(10)
# print(second_demands_id_count)
# print(second_demands_id_count)
# time.sleep(10)
# time.sleep(10)
second_demands_csv_list
=
[]
projects_csv_list
=
[]
for
tag_id
in
second_demands_tag_count
:
for
tag_id
in
second_demands_tag_count
:
temp_dict
=
{
temp_dict
=
{
"tag_name"
:
tag_id
,
"tag_name"
:
tag_id
,
"device_count"
:
second_demands_tag_count
[
tag_id
],
"device_count"
:
second_demands_tag_count
[
tag_id
],
"tractate_count"
:
second_demands_count_dict
.
get
(
tag_id
),
"tractate_count"
:
second_demands_count_dict
.
get
(
tag_id
),
"exporsure_count"
:
len
(
second_demands_id_count
[
tag_id
])
if
second_demands_id_count
.
get
(
tag_id
)
else
0
,
#
"exporsure_count": len(second_demands_id_count[tag_id]) if second_demands_id_count.get(tag_id) else 0,
}
}
print
(
temp_dict
[
'tag_name'
],
temp_dict
[
'tractate_count'
],
temp_dict
[
'exporsure_count'
],
temp_dict
[
'device_count'
],
transaction_second_demands_dict
.
get
(
tag_id
))
for
transaction_type
in
second_demands_id_count
:
if
second_demands_id_count
[
transaction_type
]
.
get
(
tag_id
):
temp_dict
[
transaction_type
]
=
len
(
second_demands_id_count
[
transaction_type
][
tag_id
])
else
:
temp_dict
[
transaction_type
]
=
0
second_demands_csv_list
.
append
(
temp_dict
)
print
(
temp_dict
)
second_demands_data
=
pandas
.
DataFrame
(
second_demands_csv_list
)
second_demands_data
.
to_csv
(
"./second_demands.csv"
,
encoding
=
'gb18030'
)
# print(temp_dict['tag_name'], temp_dict['tractate_count'], temp_dict['exporsure_count'], temp_dict['device_count'],transaction_second_demands_dict.get(tag_id))
# print(temp_dict)
# print(temp_dict)
# if temp_dict['tractate_count'] < temp_dict['exporsure_count']:
# if temp_dict['tractate_count'] < temp_dict['exporsure_count']:
# print("error" , second_demands_id_count[tag_id])
# print("error" , second_demands_id_count[tag_id])
...
@@ -412,13 +427,31 @@ for tag_id in projects_demands_tag_count:
...
@@ -412,13 +427,31 @@ for tag_id in projects_demands_tag_count:
"tag_name"
:
tag_id
,
"tag_name"
:
tag_id
,
"device_count"
:
projects_demands_tag_count
[
tag_id
],
"device_count"
:
projects_demands_tag_count
[
tag_id
],
"tractate_count"
:
tags_v3_count_dict
.
get
(
tag_id
),
"tractate_count"
:
tags_v3_count_dict
.
get
(
tag_id
),
"exporsure_coun
t"
:
len
(
projects_demands_id_count
[
tag_id
])
if
projects_demands_id_count
.
get
(
tag_id
)
else
0
,
# "exporsure_coun/
t": len(projects_demands_id_count[tag_id]) if projects_demands_id_count.get(tag_id) else 0,
}
}
# if temp_dict['tractate_count'] < temp_dict['exporsure_count']:
for
transaction_type
in
projects_demands_id_count
:
if
projects_demands_id_count
[
transaction_type
]
.
get
(
tag_id
):
temp_dict
[
transaction_type
]
=
len
(
projects_demands_id_count
[
transaction_type
][
tag_id
])
else
:
temp_dict
[
transaction_type
]
=
0
projects_csv_list
.
append
(
temp_dict
)
print
(
temp_dict
)
projects_data
=
pandas
.
DataFrame
(
projects_csv_list
)
projects_data
.
to_csv
(
"./projects.csv"
,
encoding
=
'gb18030'
)
from
crawler.maintenance.func_send_email_with_file
import
send_file_email
send_file_email
(
""
,
''
,
sender
=
"litao@igengmei.com"
,
email_group
=
[
"litao@igengmei.com"
],
email_msg_body_str
=
"test"
,
title_str
=
"test"
,
cc_group
=
[
"litao@igengmei.com"
],
file
=
"/srv/apps/meta_base_code/second_demands.csv"
)
send_file_email
(
""
,
''
,
sender
=
"litao@igengmei.com"
,
email_group
=
[
"litao@igengmei.com"
],
email_msg_body_str
=
"test"
,
title_str
=
"test"
,
cc_group
=
[
"litao@igengmei.com"
],
file
=
"/srv/apps/meta_base_code/projects.csv"
)
# if temp_dict['tractate_count'] < temp_dict['exporsure_count']:
# print("error" , projects_demands_id_count[tag_id])
# print("error" , projects_demands_id_count[tag_id])
print
(
temp_dict
[
'tag_name'
],
temp_dict
[
'tractate_count'
],
temp_dict
[
'exporsure_count'
],
temp_dict
[
'device_count'
],
transaction_projects_demands_type
.
get
(
tag_id
))
#
print(temp_dict['tag_name'], temp_dict['tractate_count'], temp_dict['exporsure_count'], temp_dict['device_count'],transaction_projects_demands_type.get(tag_id))
# print(2)
# print(2)
# for tag_id in tags_v3_count_dict:
# for tag_id in tags_v3_count_dict:
# if tag_id not in projects_demands_tag_count:
# if tag_id not in projects_demands_tag_count:
...
...
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