Porblem with xlutils/xlrd/xlwt

Discussion in 'Python' started by pp, Jan 9, 2010.

  1. pp

    pp Guest

    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')
     
    pp, Jan 9, 2010
    #1
    1. Advertising

  2. pp

    Jon Clements Guest

    On Jan 9, 10:24 am, pp <> 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.
     
    Jon Clements, Jan 9, 2010
    #2
    1. Advertising

  3. pp

    pp Guest

    On Jan 9, 3:42 am, Jon Clements <> wrote:
    > On Jan 9, 10:24 am, pp <> 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?
     
    pp, Jan 9, 2010
    #3
  4. pp

    Jon Clements Guest

    On Jan 9, 10:44 am, pp <> wrote:
    > On Jan 9, 3:42 am, Jon Clements <> wrote:
    >
    >
    >
    > > On Jan 9, 10:24 am, pp <> 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?
     
    Jon Clements, Jan 9, 2010
    #4
  5. pp

    pp Guest

    On Jan 9, 3:52 am, Jon Clements <> wrote:
    > On Jan 9, 10:44 am, pp <> wrote:
    >
    >
    >
    > > On Jan 9, 3:42 am, Jon Clements <> wrote:

    >
    > > > On Jan 9, 10:24 am, pp <> 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 ..
     
    pp, Jan 9, 2010
    #5
  6. pp

    John Machin Guest

    On Jan 9, 9:56 pm, pp <> wrote:
    > On Jan 9, 3:52 am, Jon Clements <> wrote:
    >
    >
    >
    > > On Jan 9, 10:44 am, pp <> wrote:

    >
    > > > On Jan 9, 3:42 am, Jon Clements <> wrote:

    >
    > > > > On Jan 9, 10:24 am, pp <> 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.
     
    John Machin, Jan 9, 2010
    #6
  7. pp

    pp Guest

    On Jan 9, 8:23 am, John Machin <> wrote:
    > On Jan 9, 9:56 pm, pp <> wrote:
    >
    > > On Jan 9, 3:52 am, Jon Clements <> wrote:

    >
    > > > On Jan 9, 10:44 am, pp <> wrote:

    >
    > > > > On Jan 9, 3:42 am, Jon Clements <> wrote:

    >
    > > > > > On Jan 9, 10:24 am, pp <> 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=True,
    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.
     
    pp, Jan 10, 2010
    #7
  8. pp

    John Machin Guest

    On Jan 10, 8:51 pm, pp <> wrote:
    > On Jan 9, 8:23 am, John Machin <> wrote:
    >
    >
    >
    > > On Jan 9, 9:56 pm, pp <> wrote:

    >
    > > > On Jan 9, 3:52 am, Jon Clements <> wrote:

    >
    > > > > On Jan 9, 10:44 am, pp <> wrote:

    >
    > > > > > On Jan 9, 3:42 am, Jon Clements <> wrote:

    >
    > > > > > > On Jan 9, 10:24 am, pp <> 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=True,
    > 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
     
    John Machin, Jan 10, 2010
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gandu
    Replies:
    0
    Views:
    1,078
    Gandu
    Jan 8, 2004
  2. Raffounz

    Porblem editing makefile

    Raffounz, Sep 14, 2006, in forum: C++
    Replies:
    1
    Views:
    407
    Victor Bazarov
    Sep 14, 2006
  3. Ray
    Replies:
    2
    Views:
    707
  4. Replies:
    1
    Views:
    304
    Michael Nemtsev [MVP]
    Jan 24, 2009
  5. Sameer Gupta
    Replies:
    0
    Views:
    124
    Sameer Gupta
    Oct 17, 2013
Loading...

Share This Page