in reply to How to transform the data with Perl---Solved !!!
For a clean maintainable solution you have to use a multi-dimensional array, something like this:
If you want to have each day in the database instead of only data for 'weekday' and 'weekend', you can still use above and then either copy the 'weekday' data to the 'monday', 'tuesday' slots or copy only the link (i.e. $speed[$link_no][$i++]['monday']= $speed[$link_no][$i++]['weekday'];, which would share the data, i.e. if you change data in the 'weekday' set, you also change it in the 'monday' set)#Store an entry: $speed[1][1]['weekday']= 32.61712; #or when you load values from a CSV file (I assume all values on one l +ine: my $line=<csvfile>; my @speeds= split $line; my $link_no=1; my $i=1; my $day='weekday'; foreach (@speeds) { $speed[$link_no][$i++][$day]= $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to transform the data with Perl
by hujunsimon (Sexton) on Oct 05, 2009 at 14:41 UTC | |
by ELISHEVA (Prior) on Oct 05, 2009 at 16:07 UTC | |
by hujunsimon (Sexton) on Oct 06, 2009 at 02:12 UTC | |
by ELISHEVA (Prior) on Oct 06, 2009 at 03:25 UTC | |
by hujunsimon (Sexton) on Oct 06, 2009 at 11:05 UTC | |
by Bloodnok (Vicar) on Oct 06, 2009 at 08:58 UTC |