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
f3e1ced6
authored
Aug 29, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
push message
parent
a111bf69
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
chip1stop.py
chip1stop.py
View file @
f3e1ced6
...
...
@@ -26,8 +26,8 @@ data_str = (datetime.datetime.now() + datetime.timedelta(days=-1)).strftime("%Y%
ftp_remote_path_csv
=
"/Chip1Stop_TI_included_"
+
data_str
+
"_ETCHIPS.csv.gz"
ftp_remote_path_txt
=
"/Chip1StopStockList_TI_in_ RMB_Anjie_RMB.txt.gz"
file_local_path_csv
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/tmp"
+
ftp_remote_path_csv
file_local_path_txt
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/tmp"
+
ftp_remote_path_txt
file_local_path_csv
=
str
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)
))
+
"/tmp"
+
ftp_remote_path_csv
file_local_path_txt
=
str
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)
))
+
"/tmp"
+
ftp_remote_path_txt
ENV
=
"test"
# ENV 取值 test 或 prod
...
...
@@ -111,16 +111,16 @@ class DataUtil:
return
with
open
(
file_path
,
errors
=
'ignore'
)
as
f
:
res
=
[]
p
=
Producer
()
csv_reader
=
csv
.
reader
(
f
)
for
index
,
row
in
enumerate
(
csv_reader
):
if
index
>
10
:
break
if
index
==
0
:
continue
table
=
dict
()
"""csv文件对应的是美金"""
table
[
"price_is_us"
]
=
True
table
[
"supplier_name"
]
=
"Chip1stop"
table
[
"supplier_id"
]
=
61
table
[
"ladder_price"
]
=
[]
ladder_purchases
=
dict
()
ladder_prices
=
dict
()
...
...
@@ -177,11 +177,15 @@ class DataUtil:
table
[
"ladder_price"
]
.
append
(
item
)
ans
=
json
.
dumps
(
table
)
logging
.
info
(
ans
)
p
.
push
(
ans
)
p
.
close
()
def
handle_txt
(
self
,
file_path
):
if
not
os
.
path
.
exists
(
file_path
):
return
with
open
(
file_path
,
errors
=
'ignore'
)
as
f
:
p
=
Producer
()
content_list
=
f
.
readlines
()
for
index
in
range
(
len
(
content_list
)):
if
index
==
0
:
...
...
@@ -192,6 +196,7 @@ class DataUtil:
"""RMB接口 都是txt文件格式"""
table
[
"price_is_us"
]
=
False
table
[
"supplier_name"
]
=
"Chip1stop-CN"
table
[
"supplier_id"
]
=
106
table
[
"multiple"
]
=
"1"
table
[
"batch_sn"
]
=
{}
table
[
"eccn"
]
=
""
...
...
@@ -252,7 +257,8 @@ class DataUtil:
table
[
"ladder_price"
]
.
append
(
item
)
ans
=
json
.
dumps
(
table
)
logging
.
info
(
ans
)
p
.
push
(
ans
)
p
.
close
()
class
Producer
:
...
...
@@ -279,7 +285,7 @@ class Producer:
self
.
channel
.
close
()
self
.
conn
.
close
()
except
Exception
as
e
:
print
(
e
)
logging
.
error
(
e
)
if
__name__
==
'__main__'
:
...
...
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