Have the following data:
minute, second, fraction_sec, type, ID, data1, data2, data3
Want to count the number of entries (rows) in each second when, say, type==1 && data1==0 which occur in the file for each ID. Note the IDs are letters and numbers (hexadecimal) so the only way I could think of is to create a list of IDs spotted already so that when I print out the count array I just need to go through the list of IDs that were spotted and held in ID_list.
Tried to do the counting using a 3d array:
However when I try to print this count array out by cycling through the data with nested for loops I get nothing for the minutes 0 to 9 (for all seconds) and nothing for the seconds 0 to 9 for all other minutes. Data does exist for these times!
0: 0,0,0,0,0,0,0,0,...
1: 0,0,0,0,0,0,0,0,...
etc...
9: 0,0,0,0,0,0,0,0,...
10: 0,0,0,0,0,0,0,0,0,0,7,5,32,2,5,...
11: 0,0,0,0,0,0,0,0,0,0,8,15,4,6,8,...
This is what I have been using to print out the data:
Is AWK doing something with the single digit minutes and seconds?
What has really stumped me is I can create test scripts for 1 ID which work for the single digit minutes and seconds!?!
Many Thanks for any help.
minute, second, fraction_sec, type, ID, data1, data2, data3
Want to count the number of entries (rows) in each second when, say, type==1 && data1==0 which occur in the file for each ID. Note the IDs are letters and numbers (hexadecimal) so the only way I could think of is to create a list of IDs spotted already so that when I print out the count array I just need to go through the list of IDs that were spotted and held in ID_list.
Tried to do the counting using a 3d array:
Code:
{if ($4 == 1 && $6 == 0) {
for(k=1; k <= ID_no; k++) {
if(ID_list[k] == $5) {
ID_exists = 1
break
}
}
if(ID_exists == 0) {
ID_list[ID_no] = $5
ID_no++
}
ID_exists = 0
if(count[$5,$1,$2] == "")
count[$5,$1,$2] = 1
else
count[$5,$1,$2]++
}
}
0: 0,0,0,0,0,0,0,0,...
1: 0,0,0,0,0,0,0,0,...
etc...
9: 0,0,0,0,0,0,0,0,...
10: 0,0,0,0,0,0,0,0,0,0,7,5,32,2,5,...
11: 0,0,0,0,0,0,0,0,0,0,8,15,4,6,8,...
This is what I have been using to print out the data:
Code:
for(x = 1; x < ID_no; x++) {
printf("ID: %s\n", ID_list[x])
for (y = 0; y <= 59; y++) {
printf("%d: ",y)
for (z = 0; z <= 59; z++) {
printf( "%d,", count[ID_list[x],y,z])
}
printf("\n")
}
}
What has really stumped me is I can create test scripts for 1 ID which work for the single digit minutes and seconds!?!
Many Thanks for any help.