FYI: getting data from an OpenOffice.org spreadsheet

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Sun Sep 3 18:37:46 EDT 2006


John Machin enlightened us with:
> Suppose one has over a hundred spreadsheets (real-life example:
> budgets from an organisation's reporting centres) ... manually
> opening each in OOo Calc is less than appealing, and not very
> robust.

True. There are functions that can load files as well. Combined with
the glob module, this could automatically handle all files in a
certain directory.

> With the 2nd example (alf's question: copy OOo Calc file to Excel
> xls file), I don't see any advantage at all over the manual
> procedure (1) start OOo Calc (2) open Calc file (3) File > Save As >
> select Microsoft Excel 97 etc format > ... what am I missing? Your
> solution requires (1) edit script to change name of output file;
> save script (where?) (2) start OOo Calc with magic-spell on the
> command line (3) open calc file (4) run script.

It's just a demonstration of the file saving process. Indeed, the
saving not all that useful, but someone requested it and I wrote it.

> How does one write a script that can be in control e.g. script
> starts OOo (if necessary),

That's easily done with a system call or the subprocess or popen2
modules.

> and extracts some data from all spreadsheet files in a given
> directory (while one is at lunch)? 

Just add a few lines to load the file instead of picking the currently
opened one. Do you want me to do more digging and extend the code? I'm
willing to do that, but only if it makes you happy :)

Sybren
-- 
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/



More information about the Python-list mailing list