对产品的一运营的一些关键点 的把握 : 用户对产品的 来源,入口,流失口, 波动点 :
其下 脚本算出 的是 用户在莫个 时期的波动
先把日志打成中间结果:
-bash-3.2# head /tmp/auid_ab_at.txt
9355 100015 2009-12-29
9355 100015 2009-12-29
9355 100016 2009-12-29
9355 100016 2009-12-29
9355 100015 2009-12-29
9355 100010 2009-12-29
9451 100014 2009-12-29
9397 100010 2009-12-29
9383 100010 2009-12-29
9451 100014 2009-12-29
结果 :
用户起始点 在每天的轨迹的记入集合 。
time cat /tmp/auid_ab_at.txt |perl -nle
BEGIN{
sub diffTime{
use Time::Local;
my($st1,$st2) = @_;
my $t1=timelocal(0,0,0,$3,$2-1,$1-1900) if $st1=~/(\d{4})-(\d{2})-(\d{2})/;
my $t2=timelocal(0,0,0,$3,$2-1,$1-1900) if $st2=~/(\d{4})-(\d{2})-(\d{2})/;
return ($t1-$t2)/(60*60*24);
}
}
chomp;
# ab auid time
$h{$2}{$1}{$3}++ if /(.*)\t(.*)\t(.*)/ ;
END{
use List::Util qw(first max maxstr min minstr reduce shuffle sum);
foreach my $ab (keys %h){
foreach my $auid (keys %{$h{$ab}}){
my %th = %{ $h{$ab}{$auid} } ;
my @ats = sort keys %th ;
my $tmin = $ats[0];
foreach my $at (keys %th){
my $nday = &diffTime( $at,$tmin );
print $at,"\t",$tmin if $nday < 0;
$m{$ab}{$nday}{$auid}++;
}
}
}
foreach my $ab (keys %m){
print "\n\n\n";
foreach my $nday (sort {int($a)<=>int($b)} keys %{$m{$ab}} ){
my $uv = scalar keys %{ $m{$ab}{$nday} } ;
print "$ab\t$nday\t$uv";
}
}
}
' > /tmp/ab_nday_uv.txt
|
阅读(829) | 评论(0) | 转发(0) |