[Tutor] new to python
joel at joelschwartz.com
Fri Nov 19 01:20:44 CET 2010
For those of us who are new to writing code that makes various software
packages interact with each other, can you say more about what "COM object
model" means in this context and where one can learn how to use it to make
Python interact with Excel and with Windows software in general. I've seen
term "COM" before and I know it has something to do with how Windows
programs interact with each other, but that's about it. Can you suggest some
resources for learning more?
From: tutor-bounces+joel=joelschwartz.com at python.org
[mailto:tutor-bounces+joel=joelschwartz.com at python.org] On Behalf Of Walter
Sent: Thursday, November 18, 2010 2:51 PM
To: gary engstrom
Cc: Tutor at python.org
Subject: Re: [Tutor] new to python
On 18 November 2010 21:13, gary engstrom <engstrom.gary at gmail.com> wrote:
Being new to python I was wondering if there is a way to import exel data
into pyrhon matrix/arrays so that I have some data to work with. I know R
uses Rcmdr as an easy interface
for excel data, which helps keep the reader engaged while learning the
If you want to read/write an Excel format files, have a look at the "xlwt"
and the "xlrt" Python modules (probably what Steven was aluding to). See
These modules works quite well for reading/generating Excel files (with
expectable limitations) from any platform that Python's available on (e.g.
including non-Windows) and thus does not require Excel to be available on
the machine you're producing the file on.
If however you are running on Windows and have Excel installed, you could
also consider driving the real Excel via COM automation, which will
guarantee you get desired results including formatting, charts etc when
generating sheets, and will ensure you have full access to all the
functionality Excel exposes via its COM object model.
If your requirements is simple enough though then Steven's suggestion to use
CSV is probably preferable, e.g. export the data to CSV and then import with
the "csv" module in Python. (The KISS principle applies here as elsewhere
in programming: "Keep It Small & Simple")
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor