Deep Ghodasara
Deep Ghodasara

Reputation: 962

Read cell data from excel sheet with python 3.6.x with xlrd library

This is my sample code

import xlrd

file_location=("/home/deep/Desktop/Book1.xlsx")
workbook=xlrd.open_workbook(file_location)
sheet=workbook.sheet_by_index(0)
first=sheet.cell_value(1,1)

print(first)

but i get following error into that

Traceback (most recent call last): File "/home/deep/ws/xcx.py", line 6, in workbook=xlrd.workbook(file_location) AttributeError: module 'xlrd' has no attribute 'open_workbook'

Upvotes: 3

Views: 1050

Answers (2)

theashwanisingla
theashwanisingla

Reputation: 477

open_workbook is perfectly fine to use. But at the last line, you should use:

first=sheet.cell(1,1) 
print(first.value)

Upvotes: 0

Mahesh Kumaran
Mahesh Kumaran

Reputation: 907

As per your error message ,

Traceback (most recent call last): File "/home/deep/ws/xcx.py", line 6, in workbook=xlrd.workbook(file_location) AttributeError: module'xlrd' has no attribute 'open_workbook'

I guess you've made a typo error, It says

workbook=xlrd.workbook(file_location)

It must have been:

workbook=xlrd.open_workbook(file_location)

xlrd works fine for me !! Just tried it !!

Upvotes: 1

Related Questions