
lightspd
Novice
Jul 23, 2013, 8:27 AM
Post #1 of 5
(2916 views)
|
reports and grouping
|
Can't Post
|
|
Hi All, I'm trying to create a basic report using template toolkit, that has both column and row groups. I have the data, but can't seem to wrap my mind around how to format the output. So for example
my %hash; $hash{'2013-01-01'}->{'apples'}->{'qty'} = 3; $hash{'2013-01-01'}->{'pears'}->{'qty'} = 2; $hash{'2013-01-01'}->{'peaches'}->{'qty'} = 1; $hash{'2013-01-03'}->{'peaches'}->{'qty'} = 1; $hash{'2013-01-03'}->{'apples'}->{'qty'} = 5; etc. Now in that case, I want the date to be the column header and fruit to be the row. I can think of how to group by either column or row, but not both. Example output.
2013-01-01 | 2013-01-03 apples | 3 | 5 peaches | 1 | 1 I'm open to other suggestions besides toolkit, but I am limited to Perl 5.8.8 EDIT: I created 2 hashes to pass to template toolkit, one where the main key is date and the other where it's the fruit, using my example code. I would still appreciate feedback as I'm sure my current approach isn't the best. Cheers.
(This post was edited by lightspd on Jul 23, 2013, 10:33 AM)
|