Commit 986dd4f7 authored by LAPTOP-1TK31LNP\liang's avatar LAPTOP-1TK31LNP\liang

处理类别错误数据

parent d47d0e89
This diff is collapsed.
...@@ -40,10 +40,14 @@ def all_modify_SKU_name(product_name,category_name,product_category,DATABASE): ...@@ -40,10 +40,14 @@ def all_modify_SKU_name(product_name,category_name,product_category,DATABASE):
category_name_list = df_clean[category_name].tolist() category_name_list = df_clean[category_name].tolist()
product_category_list = df_clean[product_category].tolist() product_category_list = df_clean[product_category].tolist()
import_category_list = df_clean["是否重点类"].tolist() import_category_list = df_clean["是否重点类"].tolist()
print(import_category_list)
#替换产品名称中错误的类别 #替换产品名称中错误的类别
for i in product_name_list: for i in product_name_list:
#重点类,需要生成新sku名字 #重点类,需要生成新sku名字
if import_category_list[index_row] == 1: print(import_category_list[index_row])
print(type(import_category_list[index_row]))
if import_category_list[index_row] == 1.0:
print("重点类")
temp = i.replace(category_name_list[index_row], "") temp = i.replace(category_name_list[index_row], "")
temp_1 = temp.replace(product_category_list[index_row], "") temp_1 = temp.replace(product_category_list[index_row], "")
temp_final = temp_1+" "+category_name_list[index_row] temp_final = temp_1+" "+category_name_list[index_row]
...@@ -51,9 +55,9 @@ def all_modify_SKU_name(product_name,category_name,product_category,DATABASE): ...@@ -51,9 +55,9 @@ def all_modify_SKU_name(product_name,category_name,product_category,DATABASE):
#非重点类,sku名字已经修改正确 #非重点类,sku名字已经修改正确
else: else:
list_temp.append(i) list_temp.append(i)
index_row += 1
print("Through the list") print("Through the list")
#检查替换后的列表 #检查替换后的列表
SKU_name = list_temp SKU_name = list_temp
print(SKU_name) print(SKU_name)
return SKU_name return SKU_name
...@@ -234,13 +238,13 @@ product_name = '产品名称' ...@@ -234,13 +238,13 @@ product_name = '产品名称'
product_category = '产品类别' product_category = '产品类别'
category_name = '类别名称' category_name = '类别名称'
category_id = '类别编码' category_id = '类别编码'
database = 'ZI_NEW_TEST' database = 'ZI_NEW'
test_database = 'ZI_NEW_TEST' test_database = 'ZI_NEW_TEST'
#在跑之前只需改第243行得excel文件路径和第237行得库名 #在跑之前只需改第243行得excel文件路径和第237行得库名
#df_clean = clean_excel(database) #df_clean = clean_excel(database)
df_excel = pd.read_excel('显示器产品类别分析0510.xlsx', sheet_name = 0, converters={'产品编码':str}) df_excel = pd.read_excel('平板电视类别分析0512_反馈.xlsx', sheet_name = 0, converters={'产品编码':str,'类别名称':str,'产品名称':str,'产品品牌':str,'产品类别':str,'类别编码':str,'是否为重点类': int,'备注':int})
df_clean = df_excel[df_excel['备注'] == 1] df_clean = df_excel[df_excel['备注'] == 1]
SKU_name = all_modify_SKU_name(product_name,category_name,product_category,database) SKU_name = all_modify_SKU_name(product_name,category_name,product_category,database)
SPU_name = all_modify_SPU_name(product_brand,category_name) SPU_name = all_modify_SPU_name(product_brand,category_name)
...@@ -250,7 +254,7 @@ SPU = all_match_SPU_name(database,database,SPU_name,CATEGORY_id,BRAND_id) ...@@ -250,7 +254,7 @@ SPU = all_match_SPU_name(database,database,SPU_name,CATEGORY_id,BRAND_id)
SKU = get_sku(sku) SKU = get_sku(sku)
SPU_ID = get_spu_id(SPU, database) SPU_ID = get_spu_id(SPU, database)
#print(SKU) #print(SKU)
update_sku_data(database,SKU,SKU_name,SPU_ID) #update_sku_data(database,SKU,SKU_name,SPU_ID)
#delete_data(SPU_name, test_database)删库内数据用的,少用 #delete_data(SPU_name, test_database)删库内数据用的,少用
......
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 to comment