in reply to Bucketing,Slicing and Reporting data across multiple dimensions
This may be an oversimplification, but here is one idea:
#!/usr/bin/perl -w use strict; open FIN,"<dataset.dat" or die "dataset.dat:$!"; my $buckets={}; while(my $line=<FIN>){ chomp $line; my @f=split(",",$line); unless (exists($buckets->{$f[1]}){ $buckets->{$f[1]} = { count => 0, where =>[ ] }; } if ( $f[4] > 0 ) { $buckets->{$f[1]}->{count}++; push @{$buckets->{$f[1]}},$f[0]; } } close FIN; foreach my $key (sort keys %$buckets){ next unless $buckets->{$key}->{count} > 0 ; printf "%s\t%d\t%s\n", $key,$buckets->{$key}->{count}, join(",",sort @{$buckets->{$key}->{where}}); } # ####################################################### done
Caveat: not tested.. do not use for the control of a nuclear missile launch system.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bucketing,Slicing and Reporting data across multiple dimensions
by Voronich (Hermit) on Aug 17, 2011 at 18:37 UTC | |
by blue_cowdawg (Monsignor) on Aug 17, 2011 at 18:47 UTC | |
by Voronich (Hermit) on Aug 17, 2011 at 19:00 UTC | |
by Voronich (Hermit) on Aug 17, 2011 at 20:34 UTC |