Read CSV with Linq

前端 未结 2 596
夕颜
夕颜 2021-01-07 06:08

I have the following lines (more, but this sample is fine) in a CSV file.

Date,Open,High,Low,Close,Volume,Adj Close
2012-11-01,77.60,78.12,77.37,78.05,186200         


        
2条回答
  •  滥情空心
    2021-01-07 06:30

    You can try bellow code for function 1

    var stuff = from l in File.ReadAllLines(filename)
            let x = l.Skip(1).Split(new [] {',', ' '}, StringSplitOptions.RemoveEmptyEntries)
                     .Select(s => s)
                     .select new
                        {
                          second= s[1],
                          third= s[2]
                        };
    

提交回复
热议问题