CSV File - One more time - Nth row grouping problem

  • Thread starter Thread starter phi16181
  • Start date Start date
P

phi16181

I posted an issue earlier and got a great solution (thanks gregm) so I thought Id post the ultimate nth row issue (btw the previously posted problem is a separate issue and unrelated).

Here is my problem:

I have a csv file with thousands of rows of data in the following format:

Code:
data10a
data9a
data8a
data7a
data6a
data5a
data4a
data3a
data2a
data1a
data10b
data9b
data8b
data7b
data6b
data5b
data4b
data3b
data2b
data1b
and so...

I need a solution that will eliminate all rows in each group except the first five rows so the desired output is:

Code:
data10a
data9a
data8a
data7a
data6a
data10b
data9b
data8b
data7b
data6b
BTW the data for each group is sorted from large to small by value so you could just eliminate all rows in each group except the top 5 largest as long as the ordering stays in place.

Continue reading...
 
Back
Top