Commit f3e1ced6 by 岳巧源

push message

parent a111bf69
Showing with 12 additions and 6 deletions
......@@ -26,8 +26,8 @@ data_str = (datetime.datetime.now() + datetime.timedelta(days=-1)).strftime("%Y%
ftp_remote_path_csv = "/Chip1Stop_TI_included_" + data_str + "_ETCHIPS.csv.gz"
ftp_remote_path_txt = "/Chip1StopStockList_TI_in_ RMB_Anjie_RMB.txt.gz"
file_local_path_csv = os.path.dirname(os.path.abspath(__file__)) + "/tmp" + ftp_remote_path_csv
file_local_path_txt = os.path.dirname(os.path.abspath(__file__)) + "/tmp" + ftp_remote_path_txt
file_local_path_csv = str(os.path.dirname(os.path.abspath(__file__))) + "/tmp" + ftp_remote_path_csv
file_local_path_txt = str(os.path.dirname(os.path.abspath(__file__))) + "/tmp" + ftp_remote_path_txt
ENV = "test" # ENV 取值 test 或 prod
......@@ -111,16 +111,16 @@ class DataUtil:
return
with open(file_path, errors='ignore') as f:
res = []
p = Producer()
csv_reader = csv.reader(f)
for index, row in enumerate(csv_reader):
if index > 10:
break
if index == 0:
continue
table = dict()
"""csv文件对应的是美金"""
table["price_is_us"] = True
table["supplier_name"] = "Chip1stop"
table["supplier_id"] = 61
table["ladder_price"] = []
ladder_purchases = dict()
ladder_prices = dict()
......@@ -177,11 +177,15 @@ class DataUtil:
table["ladder_price"].append(item)
ans = json.dumps(table)
logging.info(ans)
p.push(ans)
p.close()
def handle_txt(self, file_path):
if not os.path.exists(file_path):
return
with open(file_path, errors='ignore') as f:
p = Producer()
content_list = f.readlines()
for index in range(len(content_list)):
if index == 0:
......@@ -192,6 +196,7 @@ class DataUtil:
"""RMB接口 都是txt文件格式"""
table["price_is_us"] = False
table["supplier_name"] = "Chip1stop-CN"
table["supplier_id"] = 106
table["multiple"] = "1"
table["batch_sn"] = {}
table["eccn"] = ""
......@@ -252,7 +257,8 @@ class DataUtil:
table["ladder_price"].append(item)
ans = json.dumps(table)
logging.info(ans)
p.push(ans)
p.close()
class Producer:
......@@ -279,7 +285,7 @@ class Producer:
self.channel.close()
self.conn.close()
except Exception as e:
print(e)
logging.error(e)
if __name__ == '__main__':
......
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