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
23c0e13c
authored
Aug 01, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
new script
parent
fde8c83d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
element_14_data_process.py
element_14_data_process.py
View file @
23c0e13c
import
logging
import
logging
import
os.path
import
time
import
time
import
zipfile
import
zipfile
import
push
#
import push
import
requests
import
requests
url
=
"http://pfd.premierfarnell.com/eCat_element14_CN_BI.zip"
url
=
"http://pfd.premierfarnell.com/eCat_element14_CN_BI.zip"
...
@@ -14,6 +15,10 @@ save_path = "/data/golang/src/europa-erp-go/scripts/"
...
@@ -14,6 +15,10 @@ save_path = "/data/golang/src/europa-erp-go/scripts/"
logger
=
logging
.
getLogger
(
"element_14_data_process.py"
)
logger
=
logging
.
getLogger
(
"element_14_data_process.py"
)
title_map
=
{
"Brand"
,
""
}
def
download_zip_file
(
url
=
""
):
def
download_zip_file
(
url
=
""
):
start
=
time
.
time
()
start
=
time
.
time
()
response
=
requests
.
get
(
url
=
url
)
response
=
requests
.
get
(
url
=
url
)
...
@@ -30,6 +35,29 @@ def unzip_file(file=""):
...
@@ -30,6 +35,29 @@ def unzip_file(file=""):
logger
.
info
(
"文件
%
s 解压完成"
%
file
)
logger
.
info
(
"文件
%
s 解压完成"
%
file
)
class
HandleTxT
:
def
parse
(
self
,
path
:
str
):
with
open
(
path
,
encoding
=
'gbk'
,
errors
=
'ignore'
)
as
file_object
:
lines
=
file_object
.
readlines
()
data_string
=
[]
# 去除行末的换行符
for
line
in
lines
:
data_line
=
line
.
strip
(
"
\n
"
)
data_string
.
append
(
data_line
)
arr
=
data_string
[
0
]
.
split
(
"|"
)
for
i
in
range
(
len
(
arr
)):
print
(
arr
[
i
])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unzip_file
(
file_name
)
# unzip_file(file_name)
if
not
os
.
path
.
exists
(
unzip_name
):
logger
.
error
(
"文件
%
s 不存在"
%
unzip_name
)
exit
(
1
)
HandleTxT
()
.
parse
(
unzip_name
)
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