天天看點

shopify重置價格filename = ‘E:/products_export_1.csv’encoding=‘UTF-8’print(productonname)Vsku=line[13]print(longy)print(Vsku)line.append(’’)line.append(’’)print(line[0])

#--encoding:utf-8-

filename = ‘E:/products_export_1.csv’

encoding=‘UTF-8’

import xlrd

file_path = r’E:/Book3.xlsx’

#檔案路徑的中文轉碼,如果路徑非中文可以跳過

#擷取資料

data = xlrd.open_workbook(file_path)

#擷取sheet 此處有圖注釋(見圖1)

table = data.sheet_by_name(‘Sheet1’)

#擷取總行數

nrows = table.nrows

longy={}

costlist={}

for ind in range(0,nrows):

rowvalue = table.row_values(ind)

pid=str(int(rowvalue[0]))

skuid=int(rowvalue[1])

costprice=round(float(str(rowvalue[2])),2)

productonname=str(str(rowvalue[3]))

print(productonname)

longy[str(skuid)+’’]={

‘pid’:pid,

‘skuid’:skuid,

‘costprice’:costprice,

‘productonname’: str(productonname+’’)

}

import csv

filename = ‘E://ball.csv’

r = csv.reader(open(filename,encoding=‘utf-8’)) # Here your csv file

lines = [l for l in r]

for line in lines:

if line[19]‘Variant Price’:

continue

if line[19]’’:

continue

if line[13]==’’:

continue

Vsku=line[13].split("’")[1]

Vsku=line[13]

if line[46]==’’:

# print(’------------------------------’)

line[46]=str(costlist[Vsku])

# print(str(costlist[Vsku]))

print(longy)

print(Vsku)

costper=round(float(str(longy[Vsku][‘costprice’])))

print(costper)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line.append(’’)

line[45]=costper

price=round(costper,2)*2/6.5

line[19]=price

print(line[0])

oldtag=line[5]

tag=‘0-2.99’

if float(price) > 10:

tag=‘10 and above’

elif float(price) > 7.99:

tag=‘8-9.99’

elif float(price) > 4.99:

tag=‘5-7.99’

elif float(price) > 2.99:

tag=‘3-4.99’

line[5]=oldtag.replace(“0-2.99”, tag).replace(“3-4.99”, tag).replace(“5-7.99”, tag).replace(“8-9.99”, tag).replace(“10 and above”, tag);

writer = csv.writer(open(‘E:new.csv’, ‘w’,encoding=‘utf-8’,newline=’’))

writer.writerows(lines)

print(‘finsh!’)

繼續閱讀