[英]reading specified column in excel using python
So i need to output everything under a column name using python. 所以我需要使用python在列名下输出所有内容。
so far i can read in entire excel file. 到目前为止,我可以阅读整个Excel文件。 in my workbook i have many data sheets so i specfited which one to open, now i just need to only ouput everything under a specifyed column.
在我的工作簿中,我有很多数据表,因此我指定了要打开的数据表,现在我只需要在指定的列下输出所有数据即可。 Here is my code
这是我的代码
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
Update like: 更新像:
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)
If you print only row , you have something like: 如果仅打印row ,则将显示以下内容:
number:1.0
When you use .value you have only the value: 使用.value时 ,只有以下值:
1.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.