Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amazon_reports
Project
Project
Details
Activity
Releases
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
common
amazon_reports
Commits
8723ce3d
Commit
8723ce3d
authored
Oct 22, 2024
by
邱阿朋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理
parent
1a569537
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
coop.py
coop.py
+2
-2
invoices.py
invoices.py
+21
-6
No files found.
coop.py
View file @
8723ce3d
# coding: utf-8
#
回款明细
#
spa查询
import
math
import
os
import
shutil
...
...
@@ -115,7 +115,7 @@ def main():
relation_data
=
asin_sku_relations
()
# 获取 ASIN 与 SKU 的对应关系数据
coop_list
=
export_list_read_data
()
# 获取合作数据列表
coop_list
=
coop_list
[:
10
]
print
(
f
"共计:{len(coop_list)}
,
条数据"
)
print
(
f
"共计:{len(coop_list)}
条数据"
)
i
=
0
new_coop_data
=
[]
...
...
invoices.py
View file @
8723ce3d
...
...
@@ -28,7 +28,7 @@ warnings.filterwarnings("ignore", category=UserWarning, module="openpyxl")
def
export_list_read_data
():
file_name
=
'Payments.xlsx'
file_name
=
'
new_
Payments.xlsx'
if
os
.
path
.
isfile
(
file_name
):
df
=
pd
.
read_excel
(
file_name
)
return
df
...
...
@@ -36,15 +36,30 @@ def export_list_read_data():
page
.
get
(
f
"https://vendorcentral.amazon.com/hz/vendor/members/remittance/home"
,
timeout
=
3
)
page
.
ele
(
"#remittance-home-select-all"
,
timeout
=
2
)
.
click
()
page
.
ele
(
"#remittance-home-export-link"
,
timeout
=
2
)
.
click
.
to_download
()
file
.
wait_for_downloads
(
file_name
)
# file.wait_for_downloads(file_name)
all_df
=
pd
.
read_excel
(
'Payments.xlsx'
,
header
=
None
)
# 找到所有空行的索引,这里假设完全空的行为表头之间的分界线
empty_rows
=
all_df
[
all_df
.
isnull
()
.
all
(
axis
=
1
)]
.
index
.
tolist
()
# 定位表头与数据的分隔
first_header_start
=
empty_rows
[
1
]
+
1
# 第一个表头开始的行
second_header_start
=
empty_rows
[
2
]
+
3
# 第二个表头开始的行
first_df
=
pd
.
read_excel
(
'Payments.xlsx'
,
skiprows
=
first_header_start
,
nrows
=
second_header_start
-
7
)
second_df
=
pd
.
read_excel
(
'Payments.xlsx'
,
skiprows
=
second_header_start
)
df
=
pd
.
read_excel
(
file_name
,
skiprows
=
21
)
# 定义正则表达式模式,匹配包含 'Price' 或 'PCR' 或 'XXXXXXXX/XXXX/' 的描述
pattern
=
r'Price Claim|PCR|Missed Adjustment|Shortage Claim|^[A-Z0-9]{8}/[A-Z0-9]{4}/'
# 过滤符合条件的行
data
=
df
[
df
[
'Description'
]
.
str
.
contains
(
pattern
,
na
=
False
,
regex
=
True
)]
excel
.
save_xls
(
data
,
"Payments.xlsx"
,
"Remittance payments"
)
return
df
filtered_second_df
=
second_df
[
second_df
[
'Description'
]
.
str
.
contains
(
pattern
,
na
=
False
,
regex
=
True
)]
merged_df
=
pd
.
merge
(
filtered_second_df
,
first_df
[[
'Payment Number'
,
'Payment Date'
]],
on
=
'Payment Number'
,
how
=
'left'
)
excel
.
save_xls
(
merged_df
,
"new_Payments.xlsx"
,
"Remittance payments"
)
return
merged_df
def
export_details_read_data
(
invoice_number
):
# 读取详情内容
...
...
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