|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import openpyxl
import os
items = os.listdir(".")
newlist = []
for names in items:
if names.endswith(".xlsx"):
newlist.append(names)
print (newlist)
#定义t1表( )
wb_t1=openpyxl.load_workbook("t1.xlsx")
sheet_t1=wb_t1.get_sheet_by_name("t1")
row_t1=sheet_t1.max_row
#定义t2表( )
wb_t2=openpyxl.load_workbook("t2.xlsx")
sheet_t2=wb_t2.get_sheet_by_name("t2")
row_t2=sheet_t2.max_row
#定义t3表( )
wb_t3=openpyxl.load_workbook("t3.xlsx")
sheet_t3=wb_t3.get_sheet_by_name("t3")
row_t3=sheet_t3.max_row
#定义ok表(整合成结果)
ok=openpyxl.load_workbook("ok.xlsx")
sheet_ok=ok.get_sheet_by_name("ok")
row_ok=sheet_ok.max_row
temp=row_t1
temp1=row_t2
p=2
##temp=row_t1
temp=200
p=2
while(temp!=0):
##跟风 (净流入-主力金额)/主力金额
if( sheet_ok.cell(p,5).value >0 ):
sheet_ok.cell(p,13).value = ( sheet_ok.cell(p,4).value -sheet_ok.cell(p,5).value ) / sheet_ok.cell(p,5).value
##增换 今日增*换手
sheet_ok.cell(p,14).value = sheet_ok.cell(p,6).value * sheet_ok.cell(p,9).value
##差 增换-主力净量
sheet_ok.cell(p,15).value = sheet_ok.cell(p,6).value * sheet_ok.cell(p,9).value - sheet_ok.cell(p,3).value
##百分比 (净流入+主力金额)/主力金额
if( sheet_ok.cell(p,5).value >0 ):
sheet_ok.cell(p,16).value = (sheet_ok.cell(p,4).value + sheet_ok.cell(p,5).value)/sheet_ok.cell(p,5).value
##占比 主力金额/总金额
if( sheet_ok.cell(p,5).value >0 ):
sheet_ok.cell(p,17).value = sheet_ok.cell(p,5).value / sheet_ok.cell(p,11).value
p=p+1
temp=temp-1
ok.save("ok.xlsTraceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\wu.py", line 66, in <module>
sheet_ok.cell(p,13).value = ( sheet_ok.cell(p,4).value -sheet_ok.cell(p,5).value ) / sheet_ok.cell(p,5).value
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
x")
求助,如何解决?
|
|