Linq to filter data

The input file is below

after reading the input file, the datatable is as below:

The required output is as below

Any idea?