Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
python_script
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
fde8c83d
authored
Aug 01, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add new script
parent
be90278e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
element_14_data_process.py
waldom_data_process_RMB.py
waldom_data_process_USD.py
element_14_data_process.py
View file @
fde8c83d
import
logging
import
time
import
zipfile
import
push
import
requests
url
=
"http://pfd.premierfarnell.com/eCat_element14_CN_BI.zip"
file_name
=
"eCat_element14_CN_BI.zip"
unzip_name
=
"eCat_element14_CN_BI.txt"
# 解压缩的文件保存目录
save_path
=
"/data/golang/src/europa-erp-go/scripts/"
logger
=
logging
.
getLogger
(
"element_14_data_process.py"
)
def
download_zip_file
(
url
=
""
):
start
=
start
=
time
.
time
()
response
=
requests
.
get
(
url
=
url
)
with
open
(
file_name
,
'wb'
)
as
f
:
f
.
write
(
response
.
content
)
end
=
time
.
time
()
logger
.
info
(
"文件
%
s 下载完成,用时:
%
s"
%
(
file_name
,
str
(
end
-
start
)))
def
unzip_file
(
file
=
""
):
f
=
zipfile
.
ZipFile
(
file
)
logger
.
info
(
"开始解压文件
%
s "
%
file
)
f
.
extractall
(
save_path
)
logger
.
info
(
"文件
%
s 解压完成"
%
file
)
if
__name__
==
'__main__'
:
unzip_file
(
file_name
)
waldom_data_process_RMB.py
View file @
fde8c83d
...
...
@@ -43,7 +43,7 @@ ladder_map = {
}
producer
=
push
.
Producer
()
producer
.
get_connn
()
...
...
@@ -142,6 +142,7 @@ if __name__ == '__main__':
download_file
(
url
)
time
.
sleep
(
1
)
# 处理并推送json字符串数组
producer
.
get_connn
()
HandleCSV
()
.
parse
(
file_name
)
time
.
sleep
(
1
)
producer
.
close
()
...
...
waldom_data_process_USD.py
View file @
fde8c83d
...
...
@@ -25,7 +25,7 @@ ladder_map = {
file_name
=
"Tianyang_InventoryFeed.csv"
url
=
"https://www.waldomapac.com/dailyFeed/Tianyang_InventoryFeed.csv"
producer
=
push
.
Producer
()
producer
.
get_connn
()
def
download_file
(
url
=
""
):
...
...
@@ -129,6 +129,7 @@ if __name__ == '__main__':
download_file
(
url
)
time
.
sleep
(
1
)
# 处理并推送文件
producer
.
get_connn
()
HandleCSV
()
.
parse
(
file_name
)
time
.
sleep
(
1
)
producer
.
close
()
...
...
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