Harshan Gowda
Harshan Gowda

Reputation: 177

How to read .xls/excel file in python3.3

I tried a couple of ways to do so but didn't found the better way to open my excel file which is as shown in below pic.

enter image description here

Here is one of the example I tried.

import xlrd 
def read_open_exls(path): 
    book = xlrd.open_workbook(path) 
    print(book)  

if __name__ == '__main__':  
    read_open_exls(casemon.xls) 

Thanks in Advance.

Upvotes: 0

Views: 2787

Answers (1)

Ilpepe4
Ilpepe4

Reputation: 81

I'm not sure if a workbook is printable at all.

you should first select a sheet. and then you can read values from that sheet.

from openpyxl import load_workbook
wb = load_workbook(filename = 'empty_book.xlsx')
sheet_ranges = wb['range names']
print(sheet_ranges['D18'].value)

https://openpyxl.readthedocs.io/en/default/usage.html

Upvotes: 1

Related Questions