Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'm playing with the module OpenOffice and trying to extract some info from a spreadsheet to a text file. This is my program so far:

#!/usr/bin/perl use strict; use warnings; use OpenOffice::OODoc; ## module version 2.125.3, from Debian Perl Group, installed with: ## apt install libopenoffice-oodoc-perl open (my $out, '>', "outfile.txt") or die $!; my $file = ooFile("myspreadsheet.ods"); my $content = odfText(file => $file, part => 'content') or die $!; # Note: "odfText can be used in place of ooDocument() # if the calling application is only text-focused # We aren't interested in formats or styles. Perldoc" ## Write to a file the content of the non empty cells ## in the interval B1:G2001 from "sheet2" to "sheet9" ## in the .ods libreoffice spreadsheet. foreach my $sheet (1...8){ foreach my $row (0...2000){ foreach my $col (1...6){ my $value = $content->getCellValue($sheet,$row,$col); next if $value eq ""; # next if cell is empty next if $value eq "Don't keep this"; # or if match some pattern print $out $value,"\n"} # print cell content to outfile print $out "\n";} # and a newline at the end of each row print "okay, next sheet\n-------\n"; }; close $out;

When I run the program it take hours to finish. Much more slow than doing it directly with the mouse. I have also a warning message about a undefined "" value (maybe the problem is that $value is not of type string and need to be converted each time first?).

I would appreciate if you can take a look to this draft and suggest how to make it faster, or maybe point to any bug or possible memory leak. Thank you very much.


In reply to OpenOffice::OODoc. Slow access to a cell content with getCellValue by pvaldes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found