使用python读取excel中的特定列

时间:2014-08-25 20:49:33

标签: 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

1 个答案:

答案 0 :(得分:0)

更新如:

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