Commit d40100bc by 岳巧源

script

parent dbebea74
...@@ -93,6 +93,7 @@ class HandleTxT: ...@@ -93,6 +93,7 @@ class HandleTxT:
ladder_item['price_cn'] = float(str(row[j+1]).strip()) ladder_item['price_cn'] = float(str(row[j+1]).strip())
table['ladder_price'].append(ladder_item) table['ladder_price'].append(ladder_item)
json_str = json.dumps(table) json_str = json.dumps(table)
if len(str(table['brand_name'])) != 0 and len(str(table['goods_name'])) != 0:
producer.push(json_str) producer.push(json_str)
count_msg += 1 count_msg += 1
print(json_str) print(json_str)
......
...@@ -116,6 +116,7 @@ class HandleCSV: ...@@ -116,6 +116,7 @@ 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 count_msg += 1
if len(str(table['brand_name'])) != 0 and len(str(table['goods_name'])) != 0:
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 已解析" % file_name)
......
...@@ -51,6 +51,7 @@ class HandleCSV: ...@@ -51,6 +51,7 @@ class HandleCSV:
return [] return []
else: else:
json_str = self.generate_json(row, first_line) json_str = self.generate_json(row, first_line)
if json_str != "" and len(json_str) != 0:
self.push_to_mq(json_str) self.push_to_mq(json_str)
print(json_str) print(json_str)
count_msg += 1 count_msg += 1
...@@ -119,6 +120,8 @@ class HandleCSV: ...@@ -119,6 +120,8 @@ class HandleCSV:
table['batch_sn'] = batch_sn_map table['batch_sn'] = batch_sn_map
# 统一字符串处理 # 统一字符串处理
table['stock'] = str(table['stock']) table['stock'] = str(table['stock'])
if len(str(table['brand_name'])) == 0 or len(str(table['goods_name'])) == 0:
return ""
return json.dumps(table, ensure_ascii=False) return json.dumps(table, ensure_ascii=False)
def push_to_mq(self, msg: str): def push_to_mq(self, msg: str):
......
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