Hey,
I see that you have 4 headings...
site
type
date1
date2
I assume the ...'s indicate there are further dates. Is there a set number of dates or do you need the script to be able to count the number of headings - 2 (therefore the number of dates/headings)?
You should first parse the data into a hash table (use the split function) taking into account which type should be included. Then you should use the GD module to produce a graph of the data.
A very basic example of parsing the data (I did not test this, and its very rough)...
Code:
my $chosentype = 'A';
my $row = 1;
my @headings;
my %hash;
while(<FILE>){
#split the data up by the comma
my ($site,$type,@data) = split(/\,/,$_);
#if the 1st row in the file then use this row for the headings
if ($row == 1){
@headings = @data;
}
#else its actual data
else {
#if the type is the type you want to parse
if ($type eq $chosentype) {
# build the hash (using the row number as a unique identifyer of each row
$hash{$row}{'site'} = $site;
$hash{$row}{'type'} = $type;
foreach (@headings) {
$hash{$row}{$_} = shift(@data);
}
}
}
$row++;
}
That should give you an idea how to parse the data before using the GD module to produce a graph. You may probably want to change the way the hash is built to suit your data. You would probably also want to count the size of @headings/@data to ensure there are the same number of headings as there data, if not then pass into an error hash or something.
Chris