Commit 3d0f35b4 by 岳巧源

add new script

parent 7e34e35b
Showing with 8 additions and 2 deletions
......@@ -10,12 +10,13 @@ logger = logging.getLogger('waldom_data_process_USD.py')
# Manufacturer ----------------> brand_name
# 库存相加 HIJK 列
# 加一个 multiple 列
#
# TODO 缺少goods_sn
title_map = {'Part Number', 'Manufacturer', 'Stock EMEA', 'Stock USA', 'Stock APAC', 'Stock CN', 'MOQ', 'Multiplier',
'Price Break Qty 1', 'Price Break Qty 2', 'Price Break Qty 3',
'Price Break Qty 4', 'Price Break Qty 5', 'Price Break Qty 6',
'Price Break Qty 7', 'Price Break Qty 8', 'Price Break Qty 9',
'Date Code'
}
ladder_map = {
'Price Break Qty 1', 'Price Break Qty 2', 'Price Break Qty 3',
......@@ -29,6 +30,8 @@ class HandleCSV:
first_line = []
reader = csv.reader(f)
for index, row in enumerate(reader):
if index > 100:
break
if index == 0:
first_line = row
flag = self.validate(first_line)
......@@ -38,7 +41,6 @@ class HandleCSV:
else:
json_str = self.generate_json(row, first_line)
result.append(json_str)
print(json_str)
logger.info("文件 %s 已解析" % path)
return result
......@@ -56,6 +58,7 @@ class HandleCSV:
table['price_is_us'] = True
table['ladder_price'] = []
table['supplier_name'] = 'Waldom美金'
table['goods_sn'] = ''
for i in range(len(title)):
ladder_item_map = dict()
if title[i] in title_map:
......@@ -82,6 +85,9 @@ class HandleCSV:
ladder_item_map['price_us'] = float(arr[i+1])
ladder_item_map['price_cn'] = float(0)
table['ladder_price'].append(ladder_item_map)
elif title[i] == 'Date Code':
items = str(arr[i]).split(sep=";")
print(items)
return json.dumps(table, ensure_ascii=False)
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