import pandas as pd
import re
import math
dframe1 = pd.read_excel("window regulator分析报告数据对比源.xlsx", sheetname="Sheet1") #读取数据
dframe2 = pd.read_excel("window regulator分析报告数据对比源.xlsx", sheetname="Sheet2")#
dframe1["sku"] ="#" #添加一列数据,初始化为#
df = pd.DataFrame(columns = ["ebayno", "p_sku", "sale", "sku"]) #创建一个空的dataframe
# print(df)
sku = dframe2.sku.values
p_skus = dframe2.p_sku.values
# print(p_skus)
i = 0
for ps in p_skus :
dframe1.loc[dframe1.p_sku == ps,"sku"] = sku[i]
# print(dframe1.loc[dframe1.p_sku == ps])
df = df.append(dframe1.loc[dframe1.p_sku == ps], ignore_index=True) #忽略索引,往dataframe中插入一行数据
# print(df)
i = i + 1
# print(dframe1)
# print(sku.values) #将series变成数组
print(df)
df = df[["sku","ebayno","sale"]] #选取指定的列
df.to_csv("std.csv",encoding="gbk",index=False ) #写入到csv时,不要将索引写入index = False