My life is controlled by many others--a common complaint, I'm sure. I would like to convert a series of 'xls' files to 'csv' files. I've been successful on Windows machines but some of the controlling individuals have decreed that we're transitioning to Linux. After a bit of exploration, I grabbed Spreadsheet::ParseExcel from CPAN and, still on Windows, processed a single Excel file smoothly. Solved, I thought. The next file (much less complex than the first) produced an "out of memory" error--more poking found this bit (blatantly swiped from another post) that addressed the "out of memory" problem:
#!/usr/bin/perl
use strict;
use Spreadsheet::ParseExcel;
my $parse_excel =
Spreadsheet::ParseExcel->new(CellHandler => \&cell_handler,
NotSetCell => 1);
my $workbook = $parse_excel->Parse('22 JAN 2011 CRAM CFC1.xls');
sub cell_handler
{
my $workbook = $_[0];
my $sheet_index = $_[1];
my $row = $_[2];
my $col = $_[3];
my $cell = $_[4];
# Do something useful with the formatted cell value
print $cell->{Val}, "\n";
}
Then things got too strange for this Perl duffer. The offending file (79kb) is data from another group. I can't control how it's formatted. If I save the file as a 'csv' file, open that and re-save it in the 'xls' format, the script shrinks significantly and works properly. If I save the original file as another 'xls' file its size grows to 93kb and I get a completely different error.
And, if that weren't strange enough, I have another, similar file (similar size) from the same group that produces another error and it shuts down the perl interpreter.
So, am I struggling with a ParseExcel problem or, what seems more likely to me, a problem with Excel itself? Or just simple ineptitude? Always a possibility.
Many thanks for your attention.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.