利用python对cass断面格式的一种转换方法(1)
import xlrd,xlwt
wb1=xlrd.open_workbook("左.xls")
ws1=wb1.sheet_by_index(0)
wb2=xlrd.open_workbook("右.xls")
ws2=wb2.sheet_by_index(0)
nwb=xlwt.Workbook(encoding="utf-8")
nws=nwb.add_sheet("组合")
n,m=0,0
x,y=1,0
for row in range(ws1.nrows):
for col in range(ws1.ncols):
if ws1.cell_value(row,col)=="begin":
n += 2
m=0
nws.write(n,m,ws1.cell_value(row,col))
elif ws1.cell_value(row,col)!="begin":
m+=1
nws.write(n,m, ws1.cell_value(row, col))
for roww in range(ws2.nrows):
for coll in range(ws2.ncols):
if ws2.cell_value(roww,coll)=="begin":
x+=2
y=0
elif ws2.cell_value(roww,coll)!="begin":
y+=1
nws.write(x,y, ws2.cell_value(roww, coll))
nwb.save("结果.xls")