Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Porblem with xlutils/xlrd/xlwt (http://www.velocityreviews.com/forums/t711225-porblem-with-xlutils-xlrd-xlwt.html)

pp 01-09-2010 10:24 AM

Porblem with xlutils/xlrd/xlwt
 
Whenever i run the code below I get the following error:

AttributeError: 'Book' object has no attribute 'on_demand'
WARNING: Failure executing file: <copy.py>

Why is it so??

from xlrd import open_workbook
from xlwt import easyxf
from xlutils.copy import copy
rb = open_workbook('source.xls',formatting_info=True)
rs = rb.sheet_by_index(0)
wb = copy(rb)
ws = wb.get_sheet(0)
plain = easyxf('')
for i,cell in enumerate(rs.col(2)):
if not i:
continue
ws.write(i,2,cell.value,plain)
for i,cell in enumerate(rs.col(4)):
if not i:
continue
ws.write(i,4,cell.value-1000)
wb.save('output.xls')


Jon Clements 01-09-2010 10:42 AM

Re: Porblem with xlutils/xlrd/xlwt
 
On Jan 9, 10:24*am, pp <parul.pande...@gmail.com> wrote:
> Whenever i run the code below I get the following error:
>
> AttributeError: 'Book' object has no attribute 'on_demand'
> WARNING: Failure executing file: <copy.py>
>
> Why is it so??
>
> from xlrd import open_workbook
> from xlwt import easyxf
> from xlutils.copy import copy
> rb = *open_workbook('source.xls',formatting_info=True)
> rs = *rb.sheet_by_index(0)
> wb = *copy(rb)
> ws = *wb.get_sheet(0)
> plain = easyxf('')
> for i,cell in enumerate(rs.col(2)):
> * * *if not i:
> * * * * *continue
> * * *ws.write(i,2,cell.value,plain)
> for i,cell in enumerate(rs.col(4)):
> * * *if not i:
> * * * * *continue
> * * *ws.write(i,4,cell.value-1000)
> wb.save('output.xls')


I suspect your version of xlrd is not up to date (although I thought
on_demand was ages ago!).
Make sure all the tools are the latest versions from http://www.python-excel.org

There's also a dedicated Google Group for the xl* products listed on
that page.

hth
Jon.


pp 01-09-2010 10:44 AM

Re: Porblem with xlutils/xlrd/xlwt
 
On Jan 9, 3:42*am, Jon Clements <jon...@googlemail.com> wrote:
> On Jan 9, 10:24*am, pp <parul.pande...@gmail.com> wrote:
>
>
>
> > Whenever i run the code below I get the following error:

>
> > AttributeError: 'Book' object has no attribute 'on_demand'
> > WARNING: Failure executing file: <copy.py>

>
> > Why is it so??

>
> > from xlrd import open_workbook
> > from xlwt import easyxf
> > from xlutils.copy import copy
> > rb = *open_workbook('source.xls',formatting_info=True)
> > rs = *rb.sheet_by_index(0)
> > wb = *copy(rb)
> > ws = *wb.get_sheet(0)
> > plain = easyxf('')
> > for i,cell in enumerate(rs.col(2)):
> > * * *if not i:
> > * * * * *continue
> > * * *ws.write(i,2,cell.value,plain)
> > for i,cell in enumerate(rs.col(4)):
> > * * *if not i:
> > * * * * *continue
> > * * *ws.write(i,4,cell.value-1000)
> > wb.save('output.xls')

>
> I suspect your version of xlrd is not up to date (although I thought
> on_demand was ages ago!).
> Make sure all the tools are the latest versions fromhttp://www.python-excel.org
>
> There's also a dedicated Google Group for the xl* products listed on
> that page.
>
> hth
> Jon.


yeah all my versions are latest from http://www.python-excel.org .
just checked!!
what could be the problem?

Jon Clements 01-09-2010 10:52 AM

Re: Porblem with xlutils/xlrd/xlwt
 
On Jan 9, 10:44*am, pp <parul.pande...@gmail.com> wrote:
> On Jan 9, 3:42*am, Jon Clements <jon...@googlemail.com> wrote:
>
>
>
> > On Jan 9, 10:24*am, pp <parul.pande...@gmail.com> wrote:

>
> > > Whenever i run the code below I get the following error:

>
> > > AttributeError: 'Book' object has no attribute 'on_demand'
> > > WARNING: Failure executing file: <copy.py>

>
> > > Why is it so??

>
> > > from xlrd import open_workbook
> > > from xlwt import easyxf
> > > from xlutils.copy import copy
> > > rb = *open_workbook('source.xls',formatting_info=True)
> > > rs = *rb.sheet_by_index(0)
> > > wb = *copy(rb)
> > > ws = *wb.get_sheet(0)
> > > plain = easyxf('')
> > > for i,cell in enumerate(rs.col(2)):
> > > * * *if not i:
> > > * * * * *continue
> > > * * *ws.write(i,2,cell.value,plain)
> > > for i,cell in enumerate(rs.col(4)):
> > > * * *if not i:
> > > * * * * *continue
> > > * * *ws.write(i,4,cell.value-1000)
> > > wb.save('output.xls')

>
> > I suspect your version of xlrd is not up to date (although I thought
> > on_demand was ages ago!).
> > Make sure all the tools are the latest versions fromhttp://www.python-excel.org

>
> > There's also a dedicated Google Group for the xl* products listed on
> > that page.

>
> > hth
> > Jon.

>
> yeah all my versions are latest fromhttp://www.python-excel.org.
> just checked!!
> what could be the problem?


Does rb = xlrd.open_workbook('somesheet.xls', on_demand=True) work by
itself?

pp 01-09-2010 10:56 AM

Re: Porblem with xlutils/xlrd/xlwt
 
On Jan 9, 3:52*am, Jon Clements <jon...@googlemail.com> wrote:
> On Jan 9, 10:44*am, pp <parul.pande...@gmail.com> wrote:
>
>
>
> > On Jan 9, 3:42*am, Jon Clements <jon...@googlemail.com> wrote:

>
> > > On Jan 9, 10:24*am, pp <parul.pande...@gmail.com> wrote:

>
> > > > Whenever i run the code below I get the following error:

>
> > > > AttributeError: 'Book' object has no attribute 'on_demand'
> > > > WARNING: Failure executing file: <copy.py>

>
> > > > Why is it so??

>
> > > > from xlrd import open_workbook
> > > > from xlwt import easyxf
> > > > from xlutils.copy import copy
> > > > rb = *open_workbook('source.xls',formatting_info=True)
> > > > rs = *rb.sheet_by_index(0)
> > > > wb = *copy(rb)
> > > > ws = *wb.get_sheet(0)
> > > > plain = easyxf('')
> > > > for i,cell in enumerate(rs.col(2)):
> > > > * * *if not i:
> > > > * * * * *continue
> > > > * * *ws.write(i,2,cell.value,plain)
> > > > for i,cell in enumerate(rs.col(4)):
> > > > * * *if not i:
> > > > * * * * *continue
> > > > * * *ws.write(i,4,cell.value-1000)
> > > > wb.save('output.xls')

>
> > > I suspect your version of xlrd is not up to date (although I thought
> > > on_demand was ages ago!).
> > > Make sure all the tools are the latest versions fromhttp://www.python-excel.org

>
> > > There's also a dedicated Google Group for the xl* products listed on
> > > that page.

>
> > > hth
> > > Jon.

>
> > yeah all my versions are latest fromhttp://www.python-excel.org.
> > just checked!!
> > what could be the problem?

>
> Does rb = xlrd.open_workbook('somesheet.xls', on_demand=True) work by
> itself?


Yes it does. The problem is with line: wb = copy(rb)
here I am getting the error: AttributeError: 'Book' object has no
attribute 'on_demand'
Thanks ..

John Machin 01-09-2010 03:23 PM

Re: Porblem with xlutils/xlrd/xlwt
 
On Jan 9, 9:56*pm, pp <parul.pande...@gmail.com> wrote:
> On Jan 9, 3:52*am, Jon Clements <jon...@googlemail.com> wrote:
>
>
>
> > On Jan 9, 10:44*am, pp <parul.pande...@gmail.com> wrote:

>
> > > On Jan 9, 3:42*am, Jon Clements <jon...@googlemail.com> wrote:

>
> > > > On Jan 9, 10:24*am, pp <parul.pande...@gmail.com> wrote:


> > > yeah all my versions are latest fromhttp://www.python-excel.org.
> > > just checked!!


How did you check?

> > > what could be the problem?

>
> > Does rb = xlrd.open_workbook('somesheet.xls', on_demand=True) work by
> > itself?

>
> Yes it does. The problem is with line: wb = *copy(rb)
> here I am getting the error: AttributeError: 'Book' object has no
> attribute 'on_demand'


Please replace the first 4 lines of your script by these 6 lines:

import xlrd
assert xlrd.__VERSION__ == "0.7.1"
from xlwt import easyxf
from xlutils.copy import copy
rb = xlrd.open_workbook(
'source.xls',formatting_info=True, on_demand=False)

and run it again. Please copy all the output and paste it into your
response.


pp 01-10-2010 09:51 AM

Re: Porblem with xlutils/xlrd/xlwt
 
On Jan 9, 8:23*am, John Machin <sjmac...@lexicon.net> wrote:
> On Jan 9, 9:56*pm, pp <parul.pande...@gmail.com> wrote:
>
> > On Jan 9, 3:52*am, Jon Clements <jon...@googlemail.com> wrote:

>
> > > On Jan 9, 10:44*am, pp <parul.pande...@gmail.com> wrote:

>
> > > > On Jan 9, 3:42*am, Jon Clements <jon...@googlemail.com> wrote:

>
> > > > > On Jan 9, 10:24*am, pp <parul.pande...@gmail.com> wrote:
> > > > yeah all my versions are latest fromhttp://www.python-excel.org.
> > > > just checked!!

>
> How did you check?
>
> > > > what could be the problem?

>
> > > Does rb = xlrd.open_workbook('somesheet.xls', on_demand=True) work by
> > > itself?

>
> > Yes it does. The problem is with line: wb = *copy(rb)
> > here I am getting the error: AttributeError: 'Book' object has no
> > attribute 'on_demand'

>
> Please replace the first 4 lines of your script by these 6 lines:
>
> import xlrd
> assert xlrd.__VERSION__ == "0.7.1"
> from xlwt import easyxf
> from xlutils.copy import copy
> rb = xlrd.open_workbook(
> * * 'source.xls',formatting_info=True, on_demand=False)
>
> and run it again. Please copy all the output and paste it into your
> response.


This time when I ran the code sent by you I got the following
results:I am using ipython for running the code.

AssertionError Traceback (most recent call
last)

/home/parul/CODES/copy_1.py in <module>()
1
----> 2 import xlrd
3 assert xlrd.__VERSION__ == "0.7.1"
4 from xlwt import easyxf
5 from xlutils.copy import copy
6 rb = xlrd.open_workbook('source.xls',formatting_info=Tr ue,
on_demand=False)

AssertionError:
WARNING: Failure executing file: <copy_1.py>

I used www.python-excel.org to get xlrd and xlwt .. so they are latest
versions.

John Machin 01-10-2010 10:59 AM

Re: Porblem with xlutils/xlrd/xlwt
 
On Jan 10, 8:51*pm, pp <parul.pande...@gmail.com> wrote:
> On Jan 9, 8:23*am, John Machin <sjmac...@lexicon.net> wrote:
>
>
>
> > On Jan 9, 9:56*pm, pp <parul.pande...@gmail.com> wrote:

>
> > > On Jan 9, 3:52*am, Jon Clements <jon...@googlemail.com> wrote:

>
> > > > On Jan 9, 10:44*am, pp <parul.pande...@gmail.com> wrote:

>
> > > > > On Jan 9, 3:42*am, Jon Clements <jon...@googlemail.com> wrote:

>
> > > > > > On Jan 9, 10:24*am, pp <parul.pande...@gmail.com> wrote:
> > > > > yeah all my versions are latest fromhttp://www.python-excel.org.
> > > > > just checked!!

>
> > How did you check?


You didn't answer this question.

>
> > > > > what could be the problem?

>
> > > > Does rb = xlrd.open_workbook('somesheet.xls', on_demand=True) work by
> > > > itself?

>
> > > Yes it does. The problem is with line: wb = *copy(rb)
> > > here I am getting the error: AttributeError: 'Book' object has no
> > > attribute 'on_demand'

>
> > Please replace the first 4 lines of your script by these 6 lines:

>
> > import xlrd
> > assert xlrd.__VERSION__ == "0.7.1"
> > from xlwt import easyxf
> > from xlutils.copy import copy
> > rb = xlrd.open_workbook(
> > * * 'source.xls',formatting_info=True, on_demand=False)

>
> > and run it again. Please copy all the output and paste it into your
> > response.

>
> This time when I ran the code sent by you I got the following
> results:I am using ipython for running the code.
>
> AssertionError * * * * * * * * * * * * * *Traceback (most recent call
> last)
>
> /home/parul/CODES/copy_1.py in <module>()
> * * * 1
> ----> 2 import xlrd
> * * * 3 assert xlrd.__VERSION__ == "0.7.1"
> * * * 4 from xlwt import easyxf
> * * * 5 from xlutils.copy import copy
> * * * 6 rb = xlrd.open_workbook('source.xls',formatting_info=Tr ue,
> on_demand=False)
>
> AssertionError:
> WARNING: Failure executing file: <copy_1.py>
>


Your traceback appears to show an AssertionError from an import
statement. We could do without an extra layer of noise in the channel;
please consider giving ipython the flick (for debug purposes, at
least) and use Python to run your script from the shell prompt.

Change the second line to read:

print xlrd.__VERSION__

> I used www.python-excel.org to get xlrd and xlwt .. so they are latest
> versions.


Let's concentrate on xlrd. I presume that means that you clicked
on the xlrd Download link which took you to http://pypi.python.org/pypi/xlrd
from which you can download the latest version of the package. That
page has "xlrd 0.7.1" in a relatively large font at the top. You would
have been presented with options to download one of these

xlrd-0.7.1.tar.gz
xlrd-0.7.1.win32.exe
xlrd-0.7.1.zip

(each uploaded on 2009-06-01).

Which one did you download, and then what did you do with it?

Or perhaps you ignored those and read further down to "Download link"
which took you to an out-of-date page but you didn't notice the
"0.6.1" in large bold type at the top nor the "Page last updated on 11
June 2007" at the bottom nor the "0.6.1" in the name of the file that
you downloaded ... sorry about that; I've smacked the webmaster about
the chops :-)

Cheers,
John


All times are GMT. The time now is 04:54 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.