Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
python_resolve_data
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
133f5948
authored
Aug 28, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add script
parent
ef4dc21d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
3 deletions
chip1stop.py
chip1stop.py
View file @
133f5948
...
@@ -64,6 +64,8 @@ txt_title = ["Manufacturer", "mpn", "sku",
...
@@ -64,6 +64,8 @@ txt_title = ["Manufacturer", "mpn", "sku",
def
is_number
(
s
:
str
):
def
is_number
(
s
:
str
):
if
s
.
lower
()
==
"nan"
:
return
False
try
:
try
:
float
(
s
)
float
(
s
)
return
True
return
True
...
@@ -157,6 +159,8 @@ class DataUtil:
...
@@ -157,6 +159,8 @@ class DataUtil:
ladder_prices
[
"Price6"
]
=
row
[
i
]
ladder_prices
[
"Price6"
]
=
row
[
i
]
if
csv_title
[
i
]
==
"Price7"
and
row
[
i
]
!=
""
:
if
csv_title
[
i
]
==
"Price7"
and
row
[
i
]
!=
""
:
ladder_prices
[
"Price7"
]
=
row
[
i
]
ladder_prices
[
"Price7"
]
=
row
[
i
]
if
table
[
"goods_name"
]
==
""
or
table
[
"brand_name"
]
==
""
:
continue
for
k
in
range
(
1
,
8
):
for
k
in
range
(
1
,
8
):
if
"Break"
+
str
(
k
)
in
ladder_purchases
\
if
"Break"
+
str
(
k
)
in
ladder_purchases
\
and
"Price"
+
str
(
k
)
in
ladder_prices
\
and
"Price"
+
str
(
k
)
in
ladder_prices
\
...
@@ -176,8 +180,10 @@ class DataUtil:
...
@@ -176,8 +180,10 @@ class DataUtil:
with
open
(
file_path
,
errors
=
'ignore'
)
as
f
:
with
open
(
file_path
,
errors
=
'ignore'
)
as
f
:
content_list
=
f
.
readlines
()
content_list
=
f
.
readlines
()
for
index
in
range
(
len
(
content_list
)):
for
index
in
range
(
len
(
content_list
)):
if
index
==
1
:
if
index
>
10
:
break
break
if
index
==
0
:
continue
if
len
(
content_list
[
index
]
.
split
(
"
\t
"
))
!=
len
(
txt_title
):
if
len
(
content_list
[
index
]
.
split
(
"
\t
"
))
!=
len
(
txt_title
):
continue
continue
table
=
dict
()
table
=
dict
()
...
@@ -185,10 +191,13 @@ class DataUtil:
...
@@ -185,10 +191,13 @@ class DataUtil:
table
[
"price_is_us"
]
=
False
table
[
"price_is_us"
]
=
False
table
[
"supplier_name"
]
=
""
table
[
"supplier_name"
]
=
""
table
[
"multiple"
]
=
"1"
table
[
"multiple"
]
=
"1"
table
[
"batch_sn"
]
=
""
table
[
"batch_sn"
]
=
{}
table
[
"eccn"
]
=
""
table
[
"eccn"
]
=
""
table
[
"mpq"
]
=
"1"
table
[
"mpq"
]
=
"1"
table
[
"ladder_price"
]
=
[]
line_arr
=
content_list
[
index
]
.
split
(
"
\t
"
)
line_arr
=
content_list
[
index
]
.
split
(
"
\t
"
)
ladder_purchases
=
dict
()
ladder_prices
=
dict
()
for
i
in
range
(
len
(
line_arr
)):
for
i
in
range
(
len
(
line_arr
)):
element
=
line_arr
[
i
]
.
replace
(
"
\"
"
,
""
)
element
=
line_arr
[
i
]
.
replace
(
"
\"
"
,
""
)
if
txt_title
[
i
]
==
"sku"
:
if
txt_title
[
i
]
==
"sku"
:
...
@@ -201,8 +210,47 @@ class DataUtil:
...
@@ -201,8 +210,47 @@ class DataUtil:
table
[
"stock"
]
=
element
table
[
"stock"
]
=
element
if
txt_title
[
i
]
==
"MOQ"
:
if
txt_title
[
i
]
==
"MOQ"
:
table
[
"moq"
]
=
element
table
[
"moq"
]
=
element
"""阶梯价格"""
if
txt_title
[
i
]
==
"price-break-1"
and
element
!=
""
:
ladder_purchases
[
"price-break-1"
]
=
element
if
txt_title
[
i
]
==
"price-break-2"
and
element
!=
""
:
ladder_purchases
[
"price-break-2"
]
=
element
if
txt_title
[
i
]
==
"price-break-3"
and
element
!=
""
:
ladder_purchases
[
"price-break-3"
]
=
element
if
txt_title
[
i
]
==
"price-break-4"
and
element
!=
""
:
ladder_purchases
[
"price-break-4"
]
=
element
if
txt_title
[
i
]
==
"price-break-5"
and
element
!=
""
:
ladder_purchases
[
"price-break-5"
]
=
element
if
txt_title
[
i
]
==
"price-break-6"
and
element
!=
""
:
ladder_purchases
[
"price-break-6"
]
=
element
if
txt_title
[
i
]
==
"price-jpy-1"
and
element
!=
""
:
ladder_prices
[
"price-jpy-1"
]
=
element
if
txt_title
[
i
]
==
"price-jpy-2"
and
element
!=
""
:
ladder_prices
[
"price-jpy-2"
]
=
element
if
txt_title
[
i
]
==
"price-jpy-3"
and
element
!=
""
:
ladder_prices
[
"price-jpy-3"
]
=
element
if
txt_title
[
i
]
==
"price-jpy-4"
and
element
!=
""
:
ladder_prices
[
"price-jpy-4"
]
=
element
if
txt_title
[
i
]
==
"price-jpy-5"
and
element
!=
""
:
ladder_prices
[
"price-jpy-5"
]
=
element
if
txt_title
[
i
]
==
"price-jpy-6"
and
element
!=
""
:
ladder_prices
[
"price-jpy-6"
]
=
element
if
table
[
"goods_name"
]
==
""
or
table
[
"brand_name"
]
==
""
:
continue
a
=
1
for
k
in
range
(
1
,
7
):
if
"price-break-"
+
str
(
i
)
in
ladder_purchases
\
and
"price-jpy-"
+
str
(
i
)
in
ladder_prices
\
and
is_number
(
ladder_purchases
[
"price-break-"
+
str
(
i
)])
\
and
is_number
(
ladder_prices
[
"price-jpy-"
+
str
(
i
)]):
item
=
dict
()
item
[
"purchases"
]
=
int
(
ladder_purchases
[
"price-break-"
+
str
(
i
)])
item
[
"price_us"
]
=
float
(
0
)
item
[
"price_cn"
]
=
float
(
ladder_prices
[
"price-jpy-"
+
str
(
i
)])
table
[
"ladder_price"
]
.
append
(
item
)
ans
=
json
.
dumps
(
table
)
print
(
ans
)
class
Producer
:
class
Producer
:
...
@@ -231,6 +279,7 @@ class Producer:
...
@@ -231,6 +279,7 @@ class Producer:
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
# TODO 美元和人民币接口的供应商不一样
# TODO 美元和人民币接口的供应商不一样
"""
"""
供应商的名字记得修改
供应商的名字记得修改
...
...
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