Commit be90278e by 岳巧源

script

parent 8da26578
url = "http://pfd.premierfarnell.com/eCat_element14_CN_BI.zip"
def download_zip_file(url=""):
start =
...@@ -58,6 +58,7 @@ def download_file(url=""): ...@@ -58,6 +58,7 @@ def download_file(url=""):
class HandleCSV: class HandleCSV:
def parse(self, path): def parse(self, path):
df = pd.read_excel(path, sheet_name=0) df = pd.read_excel(path, sheet_name=0)
count_msg = 0
if not self.validate(df.columns.values): if not self.validate(df.columns.values):
logger.error("文件 %s 格式错误" % path) logger.error("文件 %s 格式错误" % path)
return [] return []
...@@ -113,8 +114,11 @@ class HandleCSV: ...@@ -113,8 +114,11 @@ class HandleCSV:
# 统一字符串处理 # 统一字符串处理
table['stock'] = str(table['stock']) table['stock'] = str(table['stock'])
json_str = json.dumps(table, ensure_ascii=False) json_str = json.dumps(table, ensure_ascii=False)
count_msg += 1
self.push_to_mq(json_str) self.push_to_mq(json_str)
print(json_str) print(json_str)
logger.info("文件 %s 已解析" % file_name)
logger.info("解析行数:%s" % str(count_msg))
......
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