First of all, please read the Writeup Formatting Tips - your post prior to editing was almost illegible and made your intent nearly impossible to discern. Now that we have covered that,
The Perl way of doing this would be a hash of hashes:my %error_per_file; my %error_type; while(my ($filename, $errnum) = get_row_elements($some,$params,$here)) + { $error_type{$errnum}++; $error_per_file{$filename}->{$errnum}++; }
Substitute get_row_elements() with whatever delivers your colums. You then have all filenames as keys of the %error_per_file hash. The value will be a reference to a hash, whose keys in turn are the error numbers, and the values are the number of occurences of that error.
If all of that looks very strange, I suggest reading the perlreftut tutorial and perlref documentation to understand what's going on here.
Writing them back is a bit complicated:
Now we have a hash whose keys are column headers and whose values are the corresponding column numbers. $worksheet->write(0, $column_for{$col_name}, $col_name) for keys %column_for; Here we have put the elements in their corresponding columns, at row 0 of the worksheet. Finally, we populate the rest of the rows, one at a time:my $column = 1; my %column_for = map ($_ => $column++), sort keys %error_type; $column_for{Filename} = 0;
____________my $row = 1; for my $filename (sort keys %error_per_file){ $worksheet->write($row, 0, $filename) my ($errnum, $occurences); $worksheet->write($row, $column_for{$errnum}, $occurences) while ($errnum, $occurences) = each %{$error_per_file{$filenam +e}}; ++$row; }
In reply to Re: perl and excel
by Aristotle
in thread perl and excel
by Sara
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |