Commit 40fb380a by 岳巧源

cn

parent f248e7ab
Showing with 20 additions and 13 deletions
...@@ -51,10 +51,10 @@ def handle_hk_csv(file_name): ...@@ -51,10 +51,10 @@ def handle_hk_csv(file_name):
ladder_number = [] ladder_number = []
ladder_price = [] ladder_price = []
prices = [] prices = []
message_map['batch_sn'] = {}
message_map['eccn'] = ''
message_map['goods_details'] = ''
for i in range(len(row)): for i in range(len(row)):
message_map['batch_sn'] = {}
message_map['eccn'] = ''
message_map['goods_details'] = ''
if title[i] == 'DistributorPartNumber': if title[i] == 'DistributorPartNumber':
# TODO origin goods_sn + supplier_id # TODO origin goods_sn + supplier_id
message_map["goods_sn"] = str(row[i]) + "_" message_map["goods_sn"] = str(row[i]) + "_"
...@@ -93,26 +93,29 @@ def handle_hk_csv(file_name): ...@@ -93,26 +93,29 @@ def handle_hk_csv(file_name):
def handle_cn_csv(file_name): def handle_cn_csv(file_name):
"""handle the RMB file""" """handle the RMB file"""
with open(file_name, errors='ignore') as f: with open(file_name, mode='r', errors='ignore') as f:
reader = csv.reader(f) reader = f.readlines()
title = [] title = []
for index, row in enumerate(reader): for j in range(len(reader)):
# TODO remember to delete this code. # TODO remember to delete this code.
if index > 10: if j > 10:
break break
if index == 0:
data = reader[j]
data = data.replace("\n", '')
row = data.split(sep='\t')
if j == 0:
title = row title = row
continue continue
message_map = dict() message_map = dict()
ladder_number = [] ladder_number = []
ladder_price = [] ladder_price = []
prices = [] prices = []
message_map['batch_sn'] = {}
message_map['eccn'] = ''
message_map['goods_details'] = ''
for i in range(len(row)): for i in range(len(row)):
message_map['batch_sn'] = {}
message_map['eccn'] = ''
message_map['goods_details'] = ''
if title[i] == 'DistributorPartNumber': if title[i] == 'DistributorPartNumber':
# TODO origin goods_sn + supplier_id
message_map["goods_sn"] = str(row[i]) + "_" message_map["goods_sn"] = str(row[i]) + "_"
if title[i] == 'ManufacturerPartNumber': if title[i] == 'ManufacturerPartNumber':
message_map['goods_name'] = str(row[i]) message_map['goods_name'] = str(row[i])
...@@ -134,7 +137,7 @@ def handle_cn_csv(file_name): ...@@ -134,7 +137,7 @@ def handle_cn_csv(file_name):
if row[i] == '' or len(row[i]) == 0: if row[i] == '' or len(row[i]) == 0:
continue continue
prices.append(row[i]) prices.append(row[i])
for i in range(min(len(ladder_number), len(prices))): for k in range(min(len(ladder_number), len(prices))):
item_map = dict() item_map = dict()
item_map["purchases"] = int(ladder_number[i]) item_map["purchases"] = int(ladder_number[i])
item_map["price_us"] = float(0) item_map["price_us"] = float(0)
...@@ -155,6 +158,10 @@ def handle_cn_csv(file_name): ...@@ -155,6 +158,10 @@ def handle_cn_csv(file_name):
if __name__ == '__main__': if __name__ == '__main__':
environment = sys.argv[1] environment = sys.argv[1]
if environment not in {"local", "dev", "prod"}: if environment not in {"local", "dev", "prod"}:
......
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