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
2bf6ec2a
authored
Aug 29, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add param
parent
fba2bbd2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
chip1stop.py
chip1stop.py
View file @
2bf6ec2a
...
...
@@ -4,6 +4,7 @@ import ftplib
import
gzip
import
json
import
os
import
sys
import
pika
...
...
@@ -15,15 +16,14 @@ port = 21
ftp服务器上文件名的规律 csv文件都是 带时间的
txt文件都是固定文件名
此脚本每天晚上 23:40运行 用于解析当天上传的文件
目前看 RMB接口有两个文件
"""
ftp_remote_path_csv
=
"/Chip1Stop_TI_included_"
+
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d"
)
+
"_ETCHIPS.csv.gz"
ftp_remote_path_txt
=
"/Chip1StopStockList_TI_in_ RMB_Anjie_RMB.txt.gz"
"""暂时设置为当前路径"""
# file_local_path_csv = "." + ftp_remote_path_csv
file_local_path_csv
=
"./Chip1Stop_TI_included_20240826_ETCHIPS.csv"
"""将文件名中的空格清除"""
file_local_path_txt
=
"."
+
ftp_remote_path_txt
file_local_path_csv
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/tmp"
+
ftp_remote_path_csv
.
replace
(
".gz"
,
""
)
file_local_path_txt
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/tmp"
+
ftp_remote_path_txt
.
replace
(
".gz"
,
""
)
ENV
=
"test"
# ENV 取值 test 或 prod
...
...
@@ -180,8 +180,6 @@ class DataUtil:
with
open
(
file_path
,
errors
=
'ignore'
)
as
f
:
content_list
=
f
.
readlines
()
for
index
in
range
(
len
(
content_list
)):
if
index
>
100
:
break
if
index
==
0
:
continue
if
len
(
content_list
[
index
]
.
split
(
"
\t
"
))
!=
len
(
txt_title
):
...
...
@@ -280,13 +278,22 @@ class Producer:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
<
2
:
print
(
"parameter error."
)
exit
(
1
)
ENV
=
sys
.
argv
[
1
]
if
ENV
==
"test"
:
config
=
config_test
elif
ENV
==
"prod"
:
config
=
config_prod
else
:
print
(
"parameter error."
)
exit
(
1
)
u
=
DataUtil
()
# u.download(ftp_remote_path_csv, file_local_path_csv)
# u.ungz(file_local_path_csv)
# u.download(ftp_remote_path_txt, file_local_path_txt)
# u.ungz(file_local_path_txt)
u
.
handle_txt
(
file_local_path_txt
.
replace
(
".gz"
,
""
))
# u.handle_txt(file_local_path_txt.replace(".gz", ""))
# u.handle_txt(file_local_path_txt.replace(".gz", ""))
print
(
"haha"
)
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