Commit 40fb380a by 岳巧源

cn

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