Append to an Excel file

2010-01-09 Thread pp
Hi All,

How do I add a line to an existing file. This should append to the
existing data in the excel file, which was saved previously.

Thanks,
PP
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to an Excel file

2010-01-09 Thread pp
On Jan 9, 1:47 am, Jason Scheirer  wrote:
> On Jan 9, 12:30 am, pp  wrote:
>
> > Hi All,
>
> > How do I add a line to an existing file. This should append to the
> > existing data in the excel file, which was saved previously.
>
> > Thanks,
> > PP
>
> http://pypi.python.org/pypi/xlwt

Hi Jason and all,

Thanks

I have seen this.. my question is there a  way to append to a excel
file which has been closed. Any specific modes which can be added to
the sheet so that it adds a line to the data which was return in some
earlier running of the program.


Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Porblem with xlutils/xlrd/xlwt

2010-01-09 Thread pp
Whenever i run the code below I get the following error:

AttributeError: 'Book' object has no attribute 'on_demand'
WARNING: Failure executing file: 

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')

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Porblem with xlutils/xlrd/xlwt

2010-01-09 Thread pp
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: 
>
> > 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?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Porblem with xlutils/xlrd/xlwt

2010-01-09 Thread pp
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: 
>
> > > > 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 ..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Porblem with xlutils/xlrd/xlwt

2010-01-10 Thread pp
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.

AssertionErrorTraceback (most recent call
last)

/home/parul/CODES/copy_1.py in ()
  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: 

I used www.python-excel.org to get xlrd and xlwt .. so they are latest
versions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Operations on sparse matrices

2010-04-18 Thread pp
I am currently dealing with sparse matrices and have doubts on whether
we can use
1.) dot (for matrix multiplication) and inv (inverse) operations of
numpy on sparse matrices of CSR format.

I initially constructed my sparse matrix using COO format and then
converted it to CSR format now I want to know whether normal inverse
and matrix multiplications work with sparse csr matrices.

Also can these operations be applied directly to csr matrices


Thanks a lot
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Operations on sparse matrices

2010-04-19 Thread pp
I tried csr_matrix.dot(A,N) where A and N are two sparse matrices.
 is it correct for multiplication of two sparse matrices ?
I still do not now how to perform matrix inversion for a  sparse
matrix. Can anyone please help.

Thanks!!

On Apr 19, 12:03 am, pp  wrote:
> I am currently dealing with sparse matrices and have doubts on whether
> we can use
> 1.) dot (for matrix multiplication) and inv (inverse) operations of
> numpy on sparse matrices of CSR format.
>
> I initially constructed my sparse matrix using COO format and then
> converted it to CSR format now I want to know whether normal inverse
> and matrix multiplications work with sparse csr matrices.
>
> Also can these operations be applied directly to csr matrices
>
> Thanks a lot

-- 
http://mail.python.org/mailman/listinfo/python-list


Problems with 'scipy.sparse.linalg.dsolve.umfpack'

2010-05-02 Thread pp
Hello all,

I have this equation to solve where variable
LHS is a sparse matrix and RHS is an array .
c = linsolve.spsolve(LHS, RHS)


i get this error
warn( 'scipy.sparse.linalg.dsolve.umfpack will be removed,'\
  ' install scikits.umfpack instead'
what is the reason for this and do I do next

Please help
I am very new to scipy.

Thanks a lot
-- 
http://mail.python.org/mailman/listinfo/python-list


is it possible to write python scripts in mainframe like REXX ??

2007-06-19 Thread abhilash pp

hai folks ,
i am extremely new to this list
can anybody tell me where can i find docs that are related to "sripting in
mainframe using python"
or
how can we use python instered of REXX in mainframe
how can i run python scripts in mainframe
any help will be appreciated.
thanks in advance

regards,
abhilash
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: AttributeError: module object has no attribute

2008-05-20 Thread abhilash pp
hai nikhil,
please check your __init__ file if you had any

cheers,
abhilash

On Tue, May 20, 2008 at 11:00 PM, Nikhil <[EMAIL PROTECTED]> wrote:

> I have recently written a small module. When I import the module, I always
> get the error
>
>
> only when I do
>
> >>> from local.my.module import *
>
> --
> Traceback (most recent call last):
>  File "", line 1, in 
> AttributeError: 'module' object has no attribute '/xyz/py/file'
> ---
>
>
> but when I do the below, I do not get any error.
>
> --
> >> import local.my.module
> >>
> --
>
> Any ideas on what could be wrong?
>
>
> Thanks in advance.
>
> Nikhil
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: can someone with guessing a number

2008-05-21 Thread abhilash pp
if tries > 10:
print 'you failed- give up'


On Wed, May 21, 2008 at 10:12 PM, garywood <[EMAIL PROTECTED]> wrote:

>  I would just like the program to exit after guessing the amount of
> numbers wrong
>
> # Guess My Number
> import random
> the_number = random.randrange(100) + 1
> tries = 1
> # guessing loop
> while (guess != the_number):
> if (guess > the_number):
> print "Lower..."
> else:
> print "Higher..."
>
> guess = int(raw_input("Take a guess: "))
> tries += 1
> if tries > 10:
> print 'you failed- give up'
>
> print "You guessed it!  The number was", the_number
> print "And it only took you", tries, "tries!\n"
>
> raw_input("\n\nPress the enter key to exit.")
>
> many Thanks
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: can someone with guessing a number

2008-05-21 Thread abhilash pp
if tries > 10:
print 'you failed- give up'
break
<--- use this

On Wed, May 21, 2008 at 10:24 PM, abhilash pp
<[EMAIL PROTECTED]<[EMAIL PROTECTED]>>
wrote:

>
>
> if tries > 10:
> print 'you failed- give up'
>
>
> On Wed, May 21, 2008 at 10:12 PM, garywood <[EMAIL PROTECTED]> wrote:
>
>>  I would just like the program to exit after guessing the amount of
>> numbers wrong
>>
>> # Guess My Number
>> import random
>> the_number = random.randrange(100) + 1
>> tries = 1
>> # guessing loop
>> while (guess != the_number):
>> if (guess > the_number):
>> print "Lower..."
>> else:
>> print "Higher..."
>>
>> guess = int(raw_input("Take a guess: "))
>> tries += 1
>> if tries > 10:
>> print 'you failed- give up'
>>
>> print "You guessed it!  The number was", the_number
>> print "And it only took you", tries, "tries!\n"
>>
>> raw_input("\n\nPress the enter key to exit.")
>>
>> many Thanks
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: can someone with guessing a number

2008-05-22 Thread abhilash pp
Gary,
  There is a problem in using this sys.exit()
if you are working in windows IDLE, then it will ask you for an 'exit
altogether'

so either change your 'while' clause or restructure your whole program to
fit your idea :-) to avoid failed and success messages together

cheers ,
abhilash

On Wed, May 21, 2008 at 10:35 PM, Dan Upton <[EMAIL PROTECTED]> wrote:

> On Wed, May 21, 2008 at 12:55 PM, abhilash pp <[EMAIL PROTECTED]<[EMAIL 
> PROTECTED]>>
> wrote:
> >> On Wed, May 21, 2008 at 10:12 PM, garywood <[EMAIL PROTECTED]> wrote:
> >>>
> >>> I would just like the program to exit after guessing the amount of
> >>> numbers wrong
> >>>
> >>> # Guess My Number
> >>> import random
> >>> the_number = random.randrange(100) + 1
> >>> tries = 1
> >>> # guessing loop
> >>> while (guess != the_number):
> >>> if (guess > the_number):
> >>> print "Lower..."
> >>> else:
> >>> print "Higher..."
> >>>
> >>> guess = int(raw_input("Take a guess: "))
> >>> tries += 1
> >>> if tries > 10:
> >>> print 'you failed- give up'
> >>>
> >>> print "You guessed it!  The number was", the_number
> >>> print "And it only took you", tries, "tries!\n"
> >>>
> >>> raw_input("\n\nPress the enter key to exit.")
> >>>
> >>> many Thanks
> >>> --
> >>> http://mail.python.org/mailman/listinfo/python-list
> >>
> > if tries > 10:
> > print 'you failed- give up'
> > break
> > <--- use this
> >
>
> That won't work as written, because it'll print "you failed," then
> break, then print "You guessed it!"...
>
> As an alternative to what I suggested before, if you really just want
> to end the program, you could also do
>
> from sys import exit
>
> 
>
>if tries > 10:
>print 'you failed- give up'
> exit()
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list

how can i stop script from running on login ?

2008-05-30 Thread abhilash pp
Hi all,

One of my friends played some tricky thing, and now I am in great trouble,
please help
Here is the scenario  [windows xp ]:

He wrote one login script and put it on the start program folder under 'All
Users'
The script is like this it will issue a log off command when we login; due
to this I am not able to login to my system even he himself not able to
access the system and solve the problem. The main thing is the script is of
'.pyw' type so I can't able to close the CMD window to stop this script

How can I remove that script? Any help will be appreciated, thanks in
advance

Abhilash
--
http://mail.python.org/mailman/listinfo/python-list

Re: how can i stop script from running on login ?

2008-05-30 Thread abhilash pp
thanks Benjamin, i have to try it out

On Fri, May 30, 2008 at 6:31 PM, Benjamin Kaplan <[EMAIL PROTECTED]>
wrote:

>
>
> On Fri, May 30, 2008 at 8:44 AM, abhilash pp <[EMAIL PROTECTED]<[EMAIL 
> PROTECTED]>>
> wrote:
>
>> Hi all,
>>
>> One of my friends played some tricky thing, and now I am in great trouble,
>> please help
>> Here is the scenario  [windows xp ]:
>>
>> He wrote one login script and put it on the start program folder under
>> 'All Users'
>> The script is like this it will issue a log off command when we login; due
>> to this I am not able to login to my system even he himself not able to
>> access the system and solve the problem. The main thing is the script is of
>> '.pyw' type so I can't able to close the CMD window to stop this script
>>
>> How can I remove that script? Any help will be appreciated, thanks in
>> advance
>>
>> Abhilash
>>
>>
> Try running the machine in safe mode, then delete the script.
>
>
--
http://mail.python.org/mailman/listinfo/python-list

firefox timestamp

2008-09-07 Thread abhilash pp
hi all,
--
http://mail.python.org/mailman/listinfo/python-list

firefox timestamp

2008-09-07 Thread abhilash pp
Hi all,
I don't know if this question will fit on this section,
any way my query is , i have used one script demork.py to extract details
from Firefox history.dat file
and now the problem is how to convert the TIMESTAMP given by that to normal
date and time.
example timestams are like this,

1202919771609375
1213874676203125
1215693263859375

i have used datetime module for this but it gave me error

>>> import datetime
>>> datetime.datetime.fromtimestamp(1215693263859375)

Traceback (most recent call last):
  File "", line 1, in 
datetime.datetime.fromtimestamp(1215693263859375)
ValueError: timestamp out of range for platform time_t


please help me to convert this ?
--
http://mail.python.org/mailman/listinfo/python-list

Re: firefox timestamp

2008-09-08 Thread abhilash pp
thanks Fredrik, yeah it works !!!

On Mon, Sep 8, 2008 at 8:11 PM, Fredrik Lundh <[EMAIL PROTECTED]>wrote:

> abhilash pp wrote:
>
>  I don't know if this question will fit on this section,
>> any way my query is , i have used one script demork.py to extract details
>> from Firefox history.dat file
>> and now the problem is how to convert the TIMESTAMP given by that to
>> normal date and time.
>> example timestams are like this,
>>
>> 1202919771609375
>> 1213874676203125
>> 1215693263859375
>>
>> i have used datetime module for this but it gave me error
>>
>
> a quick googling indicates that the file contains microseconds, not
> seconds.  dividing by 1e6 should do the trick:
>
> >>> t = 1202919771609375
> >>> datetime.datetime.fromtimestamp(t / 1e6)
> datetime.datetime(2008, 2, 13, 17, 22, 51, 609375)
>
> 
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list