AttributeError: 'module' object has no attribute 'open_workbook'
John Machin
sjmachin at lexicon.net
Mon Jan 26 16:37:45 EST 2009
On Jan 27, 3:07 am, MRAB <goo... at mrabarnett.plus.com> wrote:
> Jay Jesus Amorin wrote:
[snip]
> > Here's the error message:
> >
> > root at nebuchadnezzar:/home/test/project# ./xlrd.py test.xls
> > Traceback (most recent call last):
> > File "./xlrd.py", line 3, in <module>
> > import xlrd
> > File "/home/jayam/project/xlrd.py", line 6, in <module>
> > mySpreadsheet = xlrd.open_workbook(open(sys.argv[1]))
I concur with MRAB's diagnosis.
To answer the OP's possible next question: the first arg of
xlrd.open_workbook() is the path to the file to be opened. It won't
work with a string of data. That's what the file_contents arg is for.
Manual says:
"""
filename
The path to the spreadsheet file to be opened.
[snip]
file_contents
... as a string or an mmap.mmap object or some other behave-alike
object. If file_contents is supplied, filename will not be used,
except (possibly) in messages.
"""
So the above line of code should be:
mySpreadsheet = xlrd.open_workbook(sys.argv[1])
Cheers,
John
More information about the Python-list
mailing list