Append to an Excel file

P

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
 
S

Steve Holden

pp said:
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.
If you are talking about an XLS file and not a CSV then it's a highly
structured object, and you can't just "stick bits on the end" with any
expectation that Excel will know what to do with the new data. The most
likely outcomes would be Excel either complaining the file format is
invalid or ignoring the extra data.

If it's a CSV file, then f = open(file, "a") should do it.

regards
Steve
 
N

Niels L. Ellegaard

pp said:
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.

I may be wrong, but I think that you have to do the following

1) Use xlrd to read the file. This creates an xlrd.Book
2) Use xlutils to transform the xlrd.Book into a xlwt.WorkBook
3) Edit the xlwt.WorkBook
4) Save the xlwt.WorkBook

https://secure.simplistix.co.uk/svn/xlutils/trunk/xlutils/docs/copy.txt

Niels
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top