Click here to get back home

opendocument -> csv filter ?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
opendocument -> csv filter ? ivowel 09-20-2006
Posted by ivowel on September 20, 2006, 10:28 am
Please log in for more thread options



there is an openoffice perl module by Jean-Marie Gourne, but I have
never managed to figure out how to get this module to properly extract
spreadsheet data into simple csv files. (I know it needs a
decompression of repeated elements, but I could not pass it the right
parameters to make it stop complain.) has anyone written a sample
program that does this? a sample would be highly appreciated.

sincerely,

/iaw


Posted by jmgdoc on September 27, 2006, 6:29 am
Please log in for more thread options


ivowel@gmail.com wrote:

>
> there is an openoffice perl module by Jean-Marie Gourne, but I have
> never managed to figure out how to get this module to properly extract
> spreadsheet data into simple csv files. (I know it needs a
> decompression of repeated elements, but I could not pass it the right
> parameters to make it stop complain.) has anyone written a sample
> program that does this? a sample would be highly appreciated.
>
> sincerely,
>
> /iaw

There is a getTableText() method in the package; it directly exports the
content of a table as flat text, with parametrizable field/record
separators (the default separators are ";" and "\n"). It may be convenient
for simple CSV extractions. This method works with spreadsheets as well as
with tables included in text documents. Caution: in spreadsheets,
getTableText(), like any other table-related method, should be used on
previously noormalized tables (look at the normalizeSheet() and getTable()
entries in the manual).

The following example opens a spreadsheet, selects a sheet by name in a
document, then exports is as CSV:

# get a read/write handle to the content
my $doc = ooDocument(file => "mydata.ods", member => "content");
# normalize a 80x30 area in the
my $table = $doc->getTable("Sheet1", 80, 30);
# exports the content
print $doc->getTableText($table);

The CSV separators could be setting the appropriate variables in the
field_separator and line_separator instance variables of the document
handler. For example:

$doc-> = ',';

will force any subsequent getTableText() to use the comma instead of the
semicolon as CSV field terminator. The field_ and line_separator variables
cas accept any arbitrary string, so they could be used to create custom,
non-CSV markup.

Other methods, such as getCellValue(), could be used in order to build more
specific table export applications on a cell by cell basis.

All the table-related stuff of the API is described in the
OpenOffice::OODoc::Text manual chapter
(http://search.cpan.org/dist/OpenOffice-OODoc/OODoc/Text.pod)

--
JMGDOc
http://search.cpan.org/dist/OpenOffice-OODoc

Similar ThreadsPosted
MIME::Types 1.16 and OpenDocument November 9, 2005, 7:48 am
Filter::Simple bug? December 21, 2004, 9:54 pm
Email::Filter hello world August 15, 2004, 3:36 pm
where can download Filter::netcrypt February 22, 2005, 9:55 pm
Perl Tk::FBox and filter argument January 30, 2007, 2:40 pm
Printing xlated output of Filter::Simple ? November 13, 2004, 6:15 pm
can apache::filter work with virtual location? July 28, 2007, 10:36 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap