C# 最简单的读取csv文件代码
public static List<string[]> ConvertCsvToList(string fileName)
{
List<string[]> list = new List<string[]>();
using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
{
string[] headers = sr.ReadLine().Split(',');//处理头部标题
foreach (string header in headers)
{
// list.Add(headers);
}
while (!sr.EndOfStream)
{
string[] rows = sr.ReadLine().Split(',');
list.Add(rows);
}
}
return list;
}
如果觉得对你有用,请收藏并转发