Python script that writes to an Excel file

Daniel Fackrell unlearned at DELETETHIS.learn2think.org
Mon Jul 29 15:21:13 EDT 2002


"Stephen Boulet" <stephen.boulet at motorola.com> wrote in message
news:3D45894A.2090406 at motorola.com...
> What if you wanted to do things like make a tabbed spreadsheet (tabs on
> the bottom that break up a notebook int subparts, not '\t'), is this
> possible with csv format?
>
> Chris Liechti wrote:
> > keilj_33 at yahoo.com (Jeffrey Keil) wrote in
> > news:67f6bbe5.0207270544.696f6076 at posting.google.com:
> >
> >
> >>Greetings:
> >>
> >>I'd like to have a Python script open a text file, process the data in
> >>the text file and then write a report to an Excel file. I'm not sure
> >>how I would write to an Excel file from a Python script. Is there any
> >>books that would give me details on doing this?
> >
> >
> > you could use COM. but i think its simpler to write the output to a text
> > file again. use tabs to separate columns and name it .csv - excel will
> > autodetect the format and load it correctly.
> >
> > chris

>From creating such a file in MS Excel and trying to save it as a .csv file,
I got:

"The selected file type does not support workbooks that contain multiple
sheets."

Also from MS Excel Help:

"""
CSV (Comma delimited) format

The CSV (Comma delimited) file format saves only the text and values as they
are displayed in cells of the active worksheet. All rows and all characters
in each cell are saved. Columns of data are separated by commas, and each
row of data ends in a carriage return. If a cell contains a comma, the cell
contents are enclosed in double quotation marks.

If cells display formulas instead of formula values, the formulas are
converted as text. All formatting, graphics, objects, and other worksheet
contents are lost.
Note   If your workbook contains special font characters such as a copyright
symbol (©), and you will be using the converted text file on a computer with
a different operating system, save the workbook in the text file format
appropriate for that system. For example, if you are using Windows and want
to use the text file on a Macintosh computer, save the file in the CSV
(Macintosh) format. If you are using a Macintosh computer and want to use
the text file on a system running Windows or Windows NT, save the file in
the CSV (Windows) format.
"""

--
Daniel Fackrell (unlearned at learn2think.org)
When we attempt the impossible, we can experience true growth.





More information about the Python-list mailing list