N
Noatec
If I have a data set like the one below.
1st column = tape volser.
2nd column = the number of reads in the last hour.
3rd column = the last write date.
I need to sum the 2nd column for each unique volser and spit out
volser,sum,last write date.
Would anyone be interested in helping me incorporate the hash?
Sample Data:
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,2,2003-08-22
300000,2,2003-08-22
300000,2,2003-08-22
300000,2,2003-08-22
300000,3,2003-08-22
300000,3,2003-08-22
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
So on an so forth for 1500 volsers.
This is all I have so far.
#!/usr/bin/perl
use warnings;
my $line = mlist;
my $sum = 0;
# open the file
open(MLIST,"$line") or die "Unable to open mlist:$!\n";
# read it in one record at a time
while ($line = <MLIST>) {
my ($volser,$reads,$lwd) = split(/,/,$line);
printf "$volser $reads $lwd"
}
# close the file
close(MLIST);
1st column = tape volser.
2nd column = the number of reads in the last hour.
3rd column = the last write date.
I need to sum the 2nd column for each unique volser and spit out
volser,sum,last write date.
Would anyone be interested in helping me incorporate the hash?
Sample Data:
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,1,2003-08-22
300000,2,2003-08-22
300000,2,2003-08-22
300000,2,2003-08-22
300000,2,2003-08-22
300000,3,2003-08-22
300000,3,2003-08-22
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
300001,1,2003-04-21
So on an so forth for 1500 volsers.
This is all I have so far.
#!/usr/bin/perl
use warnings;
my $line = mlist;
my $sum = 0;
# open the file
open(MLIST,"$line") or die "Unable to open mlist:$!\n";
# read it in one record at a time
while ($line = <MLIST>) {
my ($volser,$reads,$lwd) = split(/,/,$line);
printf "$volser $reads $lwd"
}
# close the file
close(MLIST);