[Tutor] Select rows and columns in excel

David Holland davholla2002 at yahoo.co.uk
Thu Jul 28 16:38:04 CEST 2005


Danny and John,
 
Thanks for the pointers.  As I am leaving the project where I need to do this tomorrow, I don't think I will have time to do this, but thanks for the help anyway.
 
David

Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:


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:

http://www.python.org/doc/lib/module-csv.html

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:

http://www.oreilly.com/catalog/pythonwin32/

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

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


Hope this helps!


		
---------------------------------
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050728/e9219b74/attachment-0001.htm


More information about the Tutor mailing list