I'm trying to take an input from a file where a line contains 2 fields: (TIME, STATUS)
13:23, HELLO
15:34, BYE
16:34, TESTING
13:12, BYE
Using Python, what I've done is gotten the input file into the following format in a list:
[('13:00', 'HELLO'), ('16:00', 'TESTING'), ('18:00', 'BYE'), ('15:00', 'BYE'), ('18:00', 'HELLO'), ('13:00', 'BYE'), ('13:00', 'HELLO')]
So then I can use Counter from collections to count how many times the STATUS appears giving me the below:
Counter({('13:00', 'HELLO'): 2, ('16:00', 'TESTING'): 1, ('18:00', 'BYE'): 1, ('15:00', 'BYE'): 1, ('18:00', 'HELLO'): 1, ('13:00', 'BYE'): 1})
What I want to do is count how many times the STATUS appears and then group it based on time so that the final output is: (TIME, HELLO COUNT, BYE COUNT, TESTING COUNT)
(13:00, 2, 1, 0)
(16:00, 0, 0, 1)
(18:00, 1, 1, 0)
(15:00, 0, 1, 0)
However, I can't figure out how to get it into that format.
I tried to use a list comprehension but didn't understand as to how I can pass the counter of each STATUS into the list all at once.
Any advice as to how to go about it?