How to skip first line while reading csv using streamreader

后端 未结 5 1102
自闭症患者
自闭症患者 2020-12-14 01:21

I have my following code to read values from csv file and do some processing. I would like to skip the first row of the input csv file as it contains header text but I\'d wa

5条回答
  •  离开以前
    2020-12-14 02:10

    Just read the first line and do nothing with it...

    List values = new List();
    using (StreamReader sr = new StreamReader(filePath))
    {
        sr.ReadLine();
        while (sr.Peek() != -1)
        {
            string line = sr.ReadLine();
            List lineValues = line.Split(',').ToList();
    
            //***//
        }
    }
    

提交回复
热议问题