Commit d40100bc by 岳巧源

script

parent dbebea74
...@@ -93,7 +93,8 @@ class HandleTxT: ...@@ -93,7 +93,8 @@ 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)
producer.push(json_str) if len(str(table['brand_name'])) != 0 and len(str(table['goods_name'])) != 0:
producer.push(json_str)
count_msg += 1 count_msg += 1
print(json_str) print(json_str)
......
...@@ -116,8 +116,9 @@ class HandleCSV: ...@@ -116,8 +116,9 @@ 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
self.push_to_mq(json_str) if len(str(table['brand_name'])) != 0 and len(str(table['goods_name'])) != 0:
print(json_str) self.push_to_mq(json_str)
print(json_str)
logger.info("文件 %s 已解析" % file_name) logger.info("文件 %s 已解析" % file_name)
logger.info("解析行数:%s" % str(count_msg)) logger.info("解析行数:%s" % str(count_msg))
......
...@@ -51,7 +51,8 @@ class HandleCSV: ...@@ -51,7 +51,8 @@ class HandleCSV:
return [] return []
else: else:
json_str = self.generate_json(row, first_line) json_str = self.generate_json(row, first_line)
self.push_to_mq(json_str) if json_str != "" and len(json_str) != 0:
self.push_to_mq(json_str)
print(json_str) print(json_str)
count_msg += 1 count_msg += 1
logger.info("文件 %s 已解析" % path) logger.info("文件 %s 已解析" % path)
...@@ -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