好的,我的代码如下:
for shidx in xrange(0, book.nsheets):
print shidx
sheet = book.sheet_by_index(shidx)
d = sheet.col_values(0,2)
D = sheet.col_values(1,2)
dim = sheet.row_values(0,2)
if shidx == 0:
#numLine = sheet.row_values(2)
rs = sheet.col_values(6,2)
for i in range(4):
BB = sheet.col_values(2 + i, 2)
if BB != 0:
#print repr(d).rjust(2), repr(D).rjust(3), repr(BB).rjust(4), repr(rs).rjust(5)
file = open("C:\\calcul\\SimX18_VitesseLimite\\Documents\\ncapa-20111116\\ncapa\\resources\\output.txt", "w")
#file.write(str(table) + '\n')
file.write(str(d) + '\n')
file.write(str(D) + '\n')
file.write(str(BB) + '\n')
file.write(str(dim) + '\n')
file.write(str(rs) + '\n')
file.close()
因为我一直在尝试一些不同的东西,所以我已经在最后评论了印刷品。
我的目标是写入一个文本文件,其中每一行对应于表中的一列。我的问题是拆分 d、D、dim 和 BB 的列表。这是我想做的事情:
dim 的 ROW 和 d 的 COLUMN:
dim = [17.0, 27.0, 37.0, 47.0, u'17-47'] (see table below for the first row and to what it corresponds)
d = [0.59999999999999998, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 15.0, 17.0, 20.0, 22.0, 25.0, 28.0, 30.0, 32.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0, 100.0, 105.0, 110.0, 120.0, 130.0, 140.0, 150.0, 160.0, 170.0, 180.0, 190.0, 200.0]
以及BB的第一和第二ROW:
BB = [0.8, 0.0, 0.0, 0.0] BB = [1.0, 0.0, 0.0, 0.0]
我希望能够写入文本文件(相当于下表):
但是对于 BB 的第三行:
BB = [1.0, 0.0, 1.8, 0.0]
我需要能够获得以下内容(即有两个“暗淡”选项):
当我说 BB 不等于 0.0 时,我希望能够将 d、D、BB 和 dim 的 ONE 单个值写入表中,但我无法摆脱所有列表......
我真的希望这对某人有意义,因为我有点卡住了!