Algorithm-TicketClusterer
view release on metacpan or search on metacpan
lib/Algorithm/TicketClusterer.pm view on Meta::CPAN
|| die("\nYou forgot to specify a value for the constructor parameter clustering_fieldname that points to the data to be clustered in your Excel sheet -- ");
my $unique_id_fieldname = $self->{_unique_id_fieldname}
|| die("\nYou forgot to specify a value for the constructor parameter unique_id_fieldname that is a unique integer identifier for the rows of your Excel sheet -- ");
my $workbook;
if ($filename =~ /\.xls$/) {
my $parser = Spreadsheet::ParseExcel->new();
$workbook = $parser->parse($filename);
die $parser->error() unless defined $workbook;
} elsif ($filename =~ /\.xlsx$/) {
# use Text::Iconv;
my $converter = Text::Iconv->new("utf-8", "windows-1251");
$workbook = Spreadsheet::XLSX->new($filename, $converter);
} else {
die "File suffix on the Excel file not recognized";
}
my @worksheets = $workbook->worksheets();
my $which_worksheet = $self->{_which_worksheet} ||
die "\nYou have not specified which Excel worksheet contains the tickets\n";
my ( $row_min, $row_max ) = $worksheets[$which_worksheet-1]->row_range();
my ( $col_min, $col_max ) = $worksheets[$which_worksheet-1]->col_range();
my @good_columns;
lib/Algorithm/TicketClusterer.pm view on Meta::CPAN
$self->{_tickets_by_ids}->{$ticket->{$unique_id_fieldname}} =
lc($ticket->{$clustering_fieldname});
}
$self->{_total_num_tickets} = scalar @{$self->{_all_tickets}};
$self->store_raw_tickets_on_disk();
}
sub _test_excel_for_tickets {
my $self = shift;
use Text::Iconv;
my $converter = Text::Iconv->new("utf-8", "windows-1251");
my $filename = $self->{_excel_filename} || die("Excel sheet needed for testing is missing");
my $workbook = Spreadsheet::XLSX->new( $filename, $converter );
my @worksheets = $workbook->worksheets();
my ( $row_min, $row_max ) = $worksheets[0]->row_range();
my ( $col_min, $col_max ) = $worksheets[0]->col_range();
return ($row_min, $row_max, $col_min, $col_max);
}
sub _display_column_headers {
my $self = shift;
( run in 0.218 second using v1.01-cache-2.11-cpan-4d50c553e7e )