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
49f755c9
authored
Aug 28, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add new script
parent
7d4c2187
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
chip1stop.py
chip1stop.py
View file @
49f755c9
...
@@ -22,6 +22,7 @@ ftp_remote_path_txt = "/Chip1StopStockList RMB_Anjie_US Stock.txt.gz"
...
@@ -22,6 +22,7 @@ ftp_remote_path_txt = "/Chip1StopStockList RMB_Anjie_US Stock.txt.gz"
"""暂时设置为当前路径"""
"""暂时设置为当前路径"""
# file_local_path_csv = "." + ftp_remote_path_csv
# file_local_path_csv = "." + ftp_remote_path_csv
file_local_path_csv
=
"./Chip1Stop_TI_included_20240826_ETCHIPS.csv"
file_local_path_csv
=
"./Chip1Stop_TI_included_20240826_ETCHIPS.csv"
"""将文件名中的空格清除"""
file_local_path_txt
=
"."
+
ftp_remote_path_txt
file_local_path_txt
=
"."
+
ftp_remote_path_txt
ENV
=
"test"
# ENV 取值 test 或 prod
ENV
=
"test"
# ENV 取值 test 或 prod
...
@@ -52,6 +53,13 @@ csv_title = ['Mfr', 'C1S Part#', 'Mfr Part#', 'MOQ', 'Avail Qty', 'Days to Ship'
...
@@ -52,6 +53,13 @@ csv_title = ['Mfr', 'C1S Part#', 'Mfr Part#', 'MOQ', 'Avail Qty', 'Days to Ship'
'Break1'
,
'Break2'
,
'Break3'
,
'Break4'
,
'Break5'
,
'Break6'
,
'Break7'
,
'Break1'
,
'Break2'
,
'Break3'
,
'Break4'
,
'Break5'
,
'Break6'
,
'Break7'
,
'Price1'
,
'Price2'
,
'Price3'
,
'Price4'
,
'Price5'
,
'Price6'
,
'Price7'
,
'Date code'
]
'Price1'
,
'Price2'
,
'Price3'
,
'Price4'
,
'Price5'
,
'Price6'
,
'Price7'
,
'Date code'
]
txt_title
=
[
"Manufacturer"
,
"mpn"
,
"sku"
,
"quantity"
,
"Distributor-url"
,
"Distributor-url2"
,
"price-break-1"
,
"price-jpy-1"
,
"price-break-2"
,
"price-jpy-2"
,
"price-break-3"
,
"price-jpy-3"
,
"price-break-4"
,
"price-jpy-4"
,
"price-break-5"
,
"price-jpy-5"
,
"price-break-6"
,
"price-jpy-6"
,
"Rohs"
,
"PB"
,
"Packaging"
,
"Category"
,
"MOQ"
,
"SPQ"
,
"C1S PN"
,
"Lead-Time"
]
"""判断传入的字符串是不是数字"""
"""判断传入的字符串是不是数字"""
...
@@ -162,9 +170,30 @@ class DataUtil:
...
@@ -162,9 +170,30 @@ class DataUtil:
ans
=
json
.
dumps
(
table
)
ans
=
json
.
dumps
(
table
)
print
(
ans
)
print
(
ans
)
def
handle_txt
(
self
):
def
handle_txt
(
self
,
file_path
):
pass
if
not
os
.
path
.
exists
(
file_path
):
return
with
open
(
file_path
,
errors
=
'ignore'
)
as
f
:
content_list
=
f
.
readlines
()
for
index
in
range
(
len
(
content_list
)):
if
index
==
1
:
break
if
len
(
content_list
[
index
]
.
split
(
"
\t
"
))
!=
len
(
txt_title
):
continue
table
=
dict
()
line_arr
=
content_list
[
index
]
.
split
(
"
\t
"
)
for
i
in
range
(
len
(
line_arr
)):
element
=
line_arr
[
i
]
.
replace
(
"
\"
"
,
""
)
if
txt_title
[
i
]
==
"sku"
:
table
[
"goods_sn"
]
=
element
if
txt_title
[
i
]
==
"mpn"
:
table
[
"goods_name"
]
=
element
if
txt_title
[
i
]
==
"Manufacturer"
:
table
[
"brand_name"
]
=
element
if
txt_title
[
i
]
==
"quantity"
:
table
[
"stock"
]
=
element
if
txt_title
[
i
]
==
""
:
table
[
""
]
class
Producer
:
class
Producer
:
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -203,4 +232,5 @@ if __name__ == '__main__':
...
@@ -203,4 +232,5 @@ if __name__ == '__main__':
# u.ungz(file_local_path_csv)
# u.ungz(file_local_path_csv)
# u.download(ftp_remote_path_txt, file_local_path_txt)
# u.download(ftp_remote_path_txt, file_local_path_txt)
# u.ungz(file_local_path_txt)
# u.ungz(file_local_path_txt)
u
.
handle_csv
(
file_local_path_csv
)
u
.
handle_txt
(
file_local_path_txt
.
replace
(
".gz"
,
""
))
# u.handle_txt()
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