Hello everyone,
I am writing a script to process data from the ATP world tour.
I have a file which contains:
t=540 y=2011 r=1 p=N409
t=540 y=2011 r=2 p=N409
t=540 y=2011 r=3 p=N409
t=540 y=2011 r=4 p=N409
t=520 y=2011 r=1 p=N409
t=520 y=2011 r=2 p=N409
t=520 y=2011 r=3 p=N409
The contents of the file will get updated regularly with different `t' values (first column) and `r' values (third column). After each update of the file, I want to be always able to print the line which contains: The highest value of `r' (third column) for the first-repeating value of `t' (first column).
So, in the above version of the file I want to print the 4th line:
t=540 y=2011 r=4 p=N409
But, for example if the file gets updated to:
t=560 y=2011 r=1 p=N409
t=560 y=2011 r=2 p=N409
t=560 y=2011 r=3 p=N409
t=560 y=2011 r=4 p=N409
t=560 y=2011 r=5 p=N409
t=560 y=2011 r=6 p=N409
t=540 y=2011 r=1 p=N409
Then, I will need to print the 6th line:
t=560 y=2011 r=6 p=N409
How can I find the line based on these criteria? Your help is greatly appreciated