[Tutor] Select rows and columns in excel

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jul 27 22:47:52 CEST 2005

On Wed, 27 Jul 2005, David Holland wrote:

> I know how to open files in python, however what I want to do is select
> some information from an excel spreadsheet and save it as a .dat file.

Hi David,

Excel spreadsheets are a bit more difficult to work with.  They're not
plain text files, but have their own internal binary format, so you'll
probably need a library to deal with them.  Many people deal with Excel by
either converting the files to something plain-textish, like the 'csv'
format, or they get Python to talk to Excel directly.

If you can output your excel spreadsheet in 'csv' format, then Python's
'csv' module should be useful:


and doing the selection should just be a matter of skipping enough rows,
in the file, and then paying attention to the particular column you want.

But if you want to go another route --- to talk closely with Excel ---
that might take some more involvement, since it's so tightly bound with
Windows programming.  The book "Python Programming on Win32"  has a
chapter on how to talk to Excel through Python:


and if you're interested in this approach, you may want to talk with the
python-win32 folks:


Hope this helps!

More information about the Tutor mailing list