05月25, 2018

python按行读取xls中的某一字段

pip install pandas

报错 importerror install xlrd >= 0.9.0 for Excel support

pip install xlrd
data = xlrd.open_workbook(filename)
table = data.sheet_by_index(0)

nrows = table.nrows
ncols = table.ncols

for row in range(2, nrows):
    options = table.cell(row, 1).value
    print(options)

TypeError: coercing to Unicode: need string or buffer, int found

number = row - 1
str(number)
进行格式转换

执行命令 用

os.popen(gcc_cmd)

warning: Format not a string literal and no format arguments [duplicate] 解决方案: https://blog.csdn.net/david_xtd/article/details/8736318

Warning: this target machine does not have delayed branches

1. Documentation is wrong. "-fomit-frame-pointers" must be enabled explicitly.

import os
import xlrd
data = xlrd.open_workbook('gcc_400_result.xls')
table = data.sheet_by_index(0)

nrows = table.nrows
ncols = table.ncols
print "---------"
print nrows
print ncols

for row in range(1,nrows - 5000):
    print "---"
    print row
    print nrows - 5000
    options = table.cell(row,18).value 
    number = row 
    print '#'+str(number)
    gcc_cmd = options+' -o gcc-400-O'+str(number)+'.bin'
    #print gcc_cmd
    os.popen(gcc_cmd)

本文链接:https://harry.ren/post/read-xls.html

-- EOF --

Comments