I have a file with 2 columns, 1st column with HH: MM: SS format and second column. I want to summarize the 2nd column based on the 1st dome. in relation to the hour and minute of the 1st column.
Input:
00:00:00,2.00,
00:00:10,1.00,
00:00:20,2.00,
00:00:30,6.00,
00:00:40,1.00,
00:00:50,7.00,
00:01:00,8.00,
00:01:10,7.00,
00:01:20,8.00,
00:01:30,11.00,
Within an hour: awk works below,
awk -F, '{ a[substr($1,0,2)]+=$2 } END{ for (i in a) print i "," a[i] }' file
output:
00,53
For minutes:
it is not possible to sum the column based on the minutes submitted, please suggest a way to get the expected result.
Excluded Conclusion:
00:00,19
00:01,34
source
share