2014-08-25 3 views
1

그래서 파이썬을 사용하여 모든 열을 출력해야합니다.파이썬을 사용하여 Excel에서 지정된 열을 읽는 중

지금까지 전체 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 

답변

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) 

인쇄 할 경우에만 , 당신은 같은 것을 가지고 : 당신이 .value를 사용하는 경우

number:1.0 

당신이 값 :

1.0 
관련 문제