试图从 CSV 文件中获取排序数据。此代码工作正常,除了“Side”列是字符串并且对于一组是相同的。我无法弄清楚 First() 方法的 Single() 应该是什么参数。
var stuff = from line in File.ReadLines(@"d:\tmp\4.csv").Skip(1)
let columns = line.Split(';')
select new
{
Time = columns[0],
Side = columns[2],
Qty = columns[3],
Symbol = columns[4],
Price = columns[5],
};
var sorted = from line in stuff
group line by new { line.Time, line.Symbol }
into category
select new {
category.Key.Time,
category.Key.Symbol,
Qty = category.Sum(p => Int32.Parse(p.Qty)),
Price = category.Average(p => double.Parse(p.Price)),
Side = ?????? };