I'm getting in a mess attempting to perform grouping and computing rows from a csv file using LINQ and C#.
(sample csv)
T5,,929,,O,PPT-DAY,4,,,18.09,,ACXD:DSC,,,,,,,,,,,
T5,,929,,O,PPT-DAY,4,,,18.09,,ACXD:DSC,,,,,,,,,,,
T5,,644,,O,PPT-ANNUAL LEAVE,1,,,850.23,,INTERNAL,,,,,,,,,,,
T5,,900,,O,PPT-ANNUAL LEAVE,1,,,42.51,,INTERNAL,,,,,,,,,,,
T5,DEFAULT,674,,O,PPT-DAY,2,,,18.09,,ACXD:DSC,,,,,,,,,,,
T5,,674,,O,PPT-PERSONAL LEAVE-ON,8,,,19.9,,INTERNAL,,,,,,,,,,,
SQL equivalent
SELECT Col3
,Col5
,Col6
,SUM(Col7) as [hours]
,AVG(Col10) as [pay]
,Col12
FROM mytable
GROUP BY Col3, Col5, Col6, Col12
ORDER BY Col3, Col5, Col6, Col12
I've had a few shots at working this out using other threads but am struggling on the multi column grouping and computations. Any suggestions would be much appreciated.