Commit 6e7e8746 by larosa

add new line

parent c746c4ad
Showing with 31 additions and 6 deletions
import csv
import json
import logging
import time
import openpyxl
import pandas as pd
......@@ -46,8 +46,15 @@ class HandleCSV:
logger.error("文件 %s 格式错误" % path)
return []
for i in range(len(df.index.values)):
if i > 100:
break
# print(df.loc[i, title_arr[0]])
table = dict()
table['price_is_us'] = False
table['ladder_price'] = []
table['supplier_name'] = 'Waldom人民币'
table['goods_sn'] = ''
batch_sn_map = dict()
for j in range(len(title_arr)):
ladder_item_map = dict()
data = df.loc[i, title_arr[j]]
......@@ -67,11 +74,29 @@ class HandleCSV:
elif title_arr[j] == 'MOQ':
table['moq'] = data
elif title_arr[j] in ladder_map:
ladder_item_map['purchases'] = int(data)
ladder_item_map['price_us'] = float(0)
ladder_item_map['price_cn'] = float(df.loc[i, ladder_map[title_arr[j]]])
if len(str(data).strip()) != 0 and str(data).strip().isdigit():
ladder_item_map['purchases'] = int(data)
ladder_item_map['price_us'] = float(0)
ladder_item_map['price_cn'] = float(df.loc[i, ladder_map[title_arr[j]]])
table['ladder_price'].append(ladder_item_map)
elif title_arr[j] == 'Date Code':
pass
item_arr = str(data).split(sep=";")
for k in range(len(item_arr)):
item = item_arr[k]
split_item_arr = item.split(sep="|")
if len(split_item_arr) == 3:
number = split_item_arr[0].strip()
year = split_item_arr[1].strip()
if len(number) > 0 and len(year) >= 4 and number.isdigit() and str(year[len(year)-4:]).isdigit():
key = str(year[len(year)-2:]) + "+"
value = number
if key in batch_sn_map:
batch_sn_map[key] += int(value)
else:
batch_sn_map[key] = int(value)
table['batch_sn'] = batch_sn_map
json_str = json.dumps(table, ensure_ascii=False)
print(json_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