S
scadav
I am new to Perl and I am trying for figure out how to solve this
problem. If anyone can give me some suggestions, I would greatly
appreciate it.
I am trying to read a log file and generate some statistics from it.
For simplicity purposes (only) I have edited some of my logs and code.
Below is an example of a log file which has 3 columns (separated by
commas). The first column contains a time stamp, the second column
contains a numeric identifier and the last column contains a NYSE
Symbol:
10:00,123,KO
10:00,124,KO
10:00,123,KO
10:00,123,KO
10:00,125,T
10:00,125,T
10:20,123,KO
10:20,123,KO
10:20,126,YY
10:20,123,KO
10:20,129,PP
10:40,145,YY
10:40,147,MM
11:00,123,KO
11:00,124,KO
11:00,123,KO
11:00,123,KO
11:00,125,T
11:00,125,T
11:20,123,KO
I am trying to determine at each time interval, how many times the
numeric identifier appears. For example, I would like my output to
look something like this:
TIME NUMERIC IDENTIFIER OCCURENCES SYMBOL
10:00 123 3 KO
10:00 124 1 KO
10:00 125 2 TO
10:20 123 3 KO
10:20 126 1 YY
10:20 129 1 PP
10:40 145 1 YY
10:40 147 1 MM
11:00 123 3 KO
11:00 125 2 KO
11:00 124 1 KO
11:20 123 1 KO
Please keep in mind that my log file contains roughly 70,000 rows of
data
I have been working on this some time and I am ABLE to determine the
total number of messages in the time period (see below), but I am
UNABLE to further break it out by numeric identifier. Can anyone
recommend how I would do this? Below is how far I have gotten in the
code so far:
SAMPLE OF CODE:
$samplelog = "test2.log";
open (IN, "$samplelog");
while ($rcd = <IN>){
@fields = split(/,/,$rcd);
$time{$fields[0]}++;
}
foreach $key (sort keys(%time)) {
print "$key $time{$key} \n";
}
Thank you
problem. If anyone can give me some suggestions, I would greatly
appreciate it.
I am trying to read a log file and generate some statistics from it.
For simplicity purposes (only) I have edited some of my logs and code.
Below is an example of a log file which has 3 columns (separated by
commas). The first column contains a time stamp, the second column
contains a numeric identifier and the last column contains a NYSE
Symbol:
10:00,123,KO
10:00,124,KO
10:00,123,KO
10:00,123,KO
10:00,125,T
10:00,125,T
10:20,123,KO
10:20,123,KO
10:20,126,YY
10:20,123,KO
10:20,129,PP
10:40,145,YY
10:40,147,MM
11:00,123,KO
11:00,124,KO
11:00,123,KO
11:00,123,KO
11:00,125,T
11:00,125,T
11:20,123,KO
I am trying to determine at each time interval, how many times the
numeric identifier appears. For example, I would like my output to
look something like this:
TIME NUMERIC IDENTIFIER OCCURENCES SYMBOL
10:00 123 3 KO
10:00 124 1 KO
10:00 125 2 TO
10:20 123 3 KO
10:20 126 1 YY
10:20 129 1 PP
10:40 145 1 YY
10:40 147 1 MM
11:00 123 3 KO
11:00 125 2 KO
11:00 124 1 KO
11:20 123 1 KO
Please keep in mind that my log file contains roughly 70,000 rows of
data
I have been working on this some time and I am ABLE to determine the
total number of messages in the time period (see below), but I am
UNABLE to further break it out by numeric identifier. Can anyone
recommend how I would do this? Below is how far I have gotten in the
code so far:
SAMPLE OF CODE:
$samplelog = "test2.log";
open (IN, "$samplelog");
while ($rcd = <IN>){
@fields = split(/,/,$rcd);
$time{$fields[0]}++;
}
foreach $key (sort keys(%time)) {
print "$key $time{$key} \n";
}
Thank you