problem while using xlrd in introspection

5 views
Skip to first unread message

NikunjBadjatya

unread,
Dec 17, 2009, 6:06:38 AM12/17/09
to python-excel
hi,
I have tested the following code taken from python-excel.com
#!/usr/bin/python2.6
from xlrd import open_workbook
book = open_workbook('simple.xls')
print book.nsheets
for sheet_index in range(book.nsheets):
print book.sheet_by_index(sheet_index)
print book.sheet_names()
for sheet_name in book.sheet_names():
print book.sheet_by_name(sheet_name)
for sheet in book.sheets():
print sheet


its giving me following output :
2
<xlrd.sheet.Sheet object at 0xa24bf6c> #what does this mean??
<xlrd.sheet.Sheet object at 0xa2503ec> #what does this mean??
[u'Sheet 1', u'Sheet 2']
<xlrd.sheet.Sheet object at 0xa24bf6c> #what does this mean??
<xlrd.sheet.Sheet object at 0xa2503ec> ''
<xlrd.sheet.Sheet object at 0xa24bf6c> ''
<xlrd.sheet.Sheet object at 0xa2503ec> ''

the modules xlrd,xlutils,xlwt are installed properly.
i am using python2.6

Any help would be greatly appreciated!!

Thanks,
Niks
Bangalore, INDIA


John Machin

unread,
Dec 17, 2009, 7:55:18 AM12/17/09
to python...@googlegroups.com
On 17/12/2009 10:06 PM, NikunjBadjatya wrote:
> hi,
> I have tested the following code taken from python-excel.com

That would be www.python-excel.org, I guess ... exactly where on the site?

> #!/usr/bin/python2.6
> from xlrd import open_workbook
> book = open_workbook('simple.xls')
> print book.nsheets
> for sheet_index in range(book.nsheets):
> print book.sheet_by_index(sheet_index)
> print book.sheet_names()
> for sheet_name in book.sheet_names():
> print book.sheet_by_name(sheet_name)
> for sheet in book.sheets():
> print sheet
>
>
> its giving me following output :
> 2
> <xlrd.sheet.Sheet object at 0xa24bf6c> #what does this mean??

It shows that you have an instance of the Sheet class that's defined in
the xlrd.sheet module and the instance's memory address is 0xa24bf6c.

This is standard behaviour in the case that the class doesn't provide a
specific __str__() or __repr__() method. Example:

>>> class Foo(object):
... pass
...
>>> a = Foo()
>>> print a
<__main__.Foo object at 0x00D84530>
>>> print str(a)
<__main__.Foo object at 0x00D84530>
>>> print repr(a)
<__main__.Foo object at 0x00D84530>
>>>

Cheers,
John


Reply all
Reply to author
Forward
0 new messages