Created
April 8, 2016 08:14
-
-
Save Buttonwood/10c00424c1869c3ee8029fab63bb6dc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use List::Util qw/sum/; | |
my $gap = 2; | |
my %data; | |
while(<>){ | |
chomp; | |
my @t = split(";"); | |
my @a = split(/\s+|\:/,$t[1]); | |
my $n = int($a[1] / $gap) * $gap; | |
my $time = ($n < 10) ? "0$n:00:00" : "$n:00:00"; | |
push(@{$data{$a[0]}{$time}},$t[0]); | |
=pod | |
if($a[1] < 6){ | |
push(@{$data{$a[0]}{"00:00:00"}},$t[0]); | |
}elsif($a[1] < 12){ | |
push(@{$data{$a[0]}{"06:00:00"}},$t[0]); | |
}elsif($a[1] < 18){ | |
push(@{$data{$a[0]}{"12:00:00"}},$t[0]); | |
}else{ | |
push(@{$data{$a[0]}{"18:00:00"}},$t[0]); | |
} | |
=cut | |
#push(@{$data{$t[1]}},$t[0]); | |
} | |
use Data::Dumper; | |
#print Dumper(\%data); | |
#=pod | |
foreach my $key (sort(keys %data)){ | |
#print "$key;"; | |
#foreach ('00:00:00','06:00:00','12:00:00','18:00:00'){ | |
foreach (1 .. 24/$gap){ | |
my $n = ($_ - 1)*$gap; | |
my $time = ($n < 10) ? "0$n:00:00" : "$n:00:00"; | |
if(exists $data{$key}{$time}){ | |
my $CNT = $data{$key}{$time}; | |
if(scalar(@$CNT) > 0){ | |
printf "$key $time;%d;%0.4f;\n",scalar(@$CNT),sum(@$CNT)/scalar(@$CNT); | |
} | |
} | |
} | |
} | |
#=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment