I have a Perl program using Spreadsheet :: ParseExcel. However, two difficulties arose that arose because I could not understand how to solve them. The script for the program is as follows:
#!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; use WordNet::Similarity::lesk; use WordNet::QueryData; my $wn = WordNet::QueryData->new(); my $lesk = WordNet::Similarity::lesk->new($wn); my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse ( 'input.xls' ); if ( !defined $workbook ) { die $parser->error(), ".\n"; } WORKSHEET: for my $worksheet ( $workbook->worksheets() ) { my $sheetname = $worksheet->get_name(); my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); my $target_col; my $response_col;
So my two problems:
First of all, sometimes the program returns the error "No Excel data found in the file", even if there is data. Each Excel file is formatted the same way. There is only one sheet with columns A and B labeled "Target" and "Response", respectively, with a list of words below them. However, it does NOT ALWAYS return this error. It works for one Excel file, but it does not work for the other, although both are formatted in exactly the same way (and yes, they are both the same file type). I can not find any reason for him not reading the second file, because it is identical to the first. The only difference is that the second file was created using an Excel macro; however, why does it matter? The file types and format are exactly the same.
Secondly, the variables '$ target' and '$ response' must be formatted as strings for the expression 'my $ value' to work. How to convert them to string format? The value assigned to each variable is a word from the corresponding cell in the Excel spreadsheet. I don't know which format (and for Perl there is no explicit way to check).
Any suggestions?
Billy source share