hey folks,
I was wondering whether anyone had any tips they could give me on speeding up a Perl/Tk script that I wrote.
The script is basically a version of Excel for Unix (although with limited functionality). It will open up a CSV file and then for each value it will create an Entry box with the value in it. It is specifically made to open CSV files that my department works with these are generally 500 row x 59 column CSV files so they are pretty big.
The problem is that the script works fine, espeacially with tester csv files (20 rows x20 columns) but when it opens a big spreadsheet it takes a long time, and I mean A llllooonnnggggggggg time, although does manage it in the end. the part that slows down the script is listed below.
The problem seems to be creating so many cells, and having to store them, as it gets slower the more rows it creates!
--------Code-------------
------------------
Thanks for any help
I was wondering whether anyone had any tips they could give me on speeding up a Perl/Tk script that I wrote.
The script is basically a version of Excel for Unix (although with limited functionality). It will open up a CSV file and then for each value it will create an Entry box with the value in it. It is specifically made to open CSV files that my department works with these are generally 500 row x 59 column CSV files so they are pretty big.
The problem is that the script works fine, espeacially with tester csv files (20 rows x20 columns) but when it opens a big spreadsheet it takes a long time, and I mean A llllooonnnggggggggg time, although does manage it in the end. the part that slows down the script is listed below.
The problem seems to be creating so many cells, and having to store them, as it gets slower the more rows it creates!
--------Code-------------
Code:
while ($rowNumber < $noOfRows){
$columnNumber = 0;
$firstFlag =1;
if($rowNumber == 0){createTheHeadingLine();}
while($columnNumber < $noOfColumns){
$cellReference = "cell".$columnNumber."line".$rowNumber;
$cellVariable = $cellReference."var";
$createCell = "\$".$cellReference."= \$canvas -> Entry(-textvariable => \\\$".$cellVariable.", -width => 11, -relief => 'ridge')\;";
eval($createCell);
if ($@){ #error catching
print "(create cell) Eval didn't work: $@ \n";
undef ($@);
}
if ($columnNumber ==0){
$gridValue = "\$sideCellReference ->grid(\$cell0line".$rowNumber;
}elsif($columnNumber > 0){
$gridValue = $gridValue.", \$".$cellReference;
}
$columnNumber++;
}
print "\tstart New Row number $rowNumber\n";
$gridValue = $gridValue.", -sticky => 'nw')\;";
#print "\$gridValue = $gridValue\n";
eval($gridValue);
if ($@){
print "(create grid) Eval didn't work: $@\n";
undef ($@);
}
undef($evalValue);
$rowNumber++;
}
Thanks for any help