Home > OS >  Consult everybody eldest brother a scheduling problem
Consult everybody eldest brother a scheduling problem

Time:10-18

The text is as follows:
Q1, d1, 5
Q1, d2, 6
Q1, d3, 7
Q1, d4, 8
Q1, d5, 9
Q2, d1, 5
Q2, d2, 6
Q2, d3, 7
Q2, d4, 8
Q2, d5, 9
Q3, d1, 5
Q3, d2, 6
Q3, d3, 7

My request is that the first column of the same situation in the third column scores the highest two, take a few requirements can be customized, hope that the result is as follows:
Q1, d5, 9
Q1, d4, 8
Q2, d5, 9
Q2, d4, 8
Q3, d3, 7
Q3, d2, 6
Asked for PYTHON2 or shell, thank you for your brother!

CodePudding user response:

Modify the number of control output LIMIT variables in awk

 
The cat test. TXT | sort -t ', '- k1, 1 - k3gr | awk - F', ' 'the BEGIN {LIMIT=2; Count=0} {a (NR)=$1; If (a (NR)==a NR - [1]) {count +=1} else {count=0}; If (count '
  • Related