How to read data in specific column of XLSX file using python script -


i want read data given in 2nd , 3rd column xlsx file.

import xlrd  workbook = xlrd.open_workbook("c:/users/file.xlsx","rb") sheet = workbook.sheet_by_index(0) row in range(sheet.nrows):     cols = (sheet.row_values(row,1)) , (sheet.row_values(row,2))     print(cols) 

but gives below error when executed above script..

biff_version = bk.getbof(xl_workbook_globals) file c:\python27\.....\xlrd_init_.py", line 1323, in getbof raise xlrderror('expected bof record; found 0x%04x' % opcode) xlrd.biffh.xlrderror: expected bof record; found 0x4b50 

try this

import xlrd  workbook = xlrd.open_workbook("c:/users/file.xlsx","rb") sheets = workbook.sheet_names() required_data = [] sheet_name in sheets:     sh = workbook.sheet_by_name(sheet_name)     rownum in range(sh.nrows):         row_valaues = sh.row_values(rownum)         required_data.append((row_valaues[0], row_valaues[1])) print required_data 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -