Commit 23c0e13c by 岳巧源

new script

parent fde8c83d
Showing with 30 additions and 2 deletions
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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment