I have some data which i want to parse and then based on that, i have to take the data for the date which is minimun for each group.
Data files is as below ( a small sinppet)
D_REPDATE;INDEX;MATLABEL;ST_START;ST_END;QT_START;QT_END;PRC_RF0;PRC_RF1
APR-13;04/01/13;F35MEDFC;APR-13;01/04/13;30/04/13;01/04/11;29/03/13;596.02000;596.02000
APR-14;04/01/13;F35MEDFC;APR-14;01/04/14;30/04/14;30/03/12;31/03/14;581.77000;581.77000
APR-15;04/01/13;F35MEDFC;APR-15;01/04/15;30/04/15;01/04/13;31/03/15;567.27000;567.27000
APR-16;04/01/13;F35MEDFC;APR-16;01/04/16;30/04/16;01/04/14;31/03/16;556.52000;556.52000
APR-17;04/01/13;F35MEDFC;APR-17;01/04/17;30/04/17;01/04/15;31/03/17;548.77000;548.77000
APR-13;04/01/13;BR DATED;APR-13;01/04/13;30/04/13;01/04/11;29/03/13;108.46000;108.46000
APR-14;04/01/13;BR DATED;APR-14;01/04/14;30/04/14;30/03/12;31/03/14;102.53000;102.53000
APR-15;04/01/13;BR DATED;APR-15;01/04/15;30/04/15;01/04/13;31/03/15;98.19000;98.19000
APR-16;04/01/13;BR DATED;APR-16;01/04/16;30/04/16;01/04/14;31/03/16;94.49000;94.49000
JAN-21;04/01/13;F630GCW;JAN-21;01/01/21;31/01/21;01/01/19;31/12/20;85.57000;85.57000
JUL-13;04/01/13;F630GCW;JUL-13;01/07/13;31/07/13;01/07/11;28/06/13;93.50000;93.50000
JUL-14;04/01/13;F630GCW;JUL-14;01/07/14;31/07/14;29/06/12;30/06/14;90.95000;90.95000
JUL-15;04/01/13;F630GCW;JUL-15;01/07/15;31/07/15;01/07/13;30/06/15;88.83000;88.83000
JUL-16;04/01/13;F630GCW;JUL-16;01/07/16;31/07/16;01/07/14;30/06/16;87.01000;87.01000
For each index for the min QT_END i want to read the PRC_RF0.
I have written something like
class GMRTest
{
public string CRVLABEL;
public string INDEX;
public string MATLABEL;
public DateTime ST_START;
public DateTime ST_END;
public DateTime QT_START;
public DateTime QT_END;
public string PRC_RF0;
public string PRC_RF1;
}
and reading this method into a list (listData)
listData.GroupBy(s => s.INDEX).Select( aa => new {Key = aa.Key, Data = aa.OrderBy(ab => ab.ST_START) } );
However this is still giveing me all the data, what i want is the data with the min date (ST_START).
Any help is appreciated.
Thanks
Try to append
First()after yourOrderBycall. Example: