使用python读取excel中的指定列
所以我需要使用python输出一个列名下的所有东西。
到目前为止,我可以阅读整个Excel文件。 在我的工作簿中,我有很多数据表,所以我指定了哪一个打开,现在我只需要输出指定列下的所有东西。 这是我的代码
import xlrd file_Location = "/home/jerad/Desktop/Register.xlsx" workbook = xlrd.open_workbook(file_Location) sheet = workbook.sheet_by_name('CM4000 Register View') num_rows = sheet.nrows - 1 curr_row = -1 while curr_row < num_rows: curr_row += 1 row = sheet.row(curr_row) #this is print everything in the file. print row
更新如下:
while curr_row < num_rows: curr_row += 1 row = sheet.cell(curr_row,1) #this is print only the cells selected (Index Start from 0). print (row.value)
如果您只打印行 ,您有这样的东西:
number:1.0
当你使用.value你只有价值:
1.0