我有以下字符串。
我该如何将其转换为
const string csv = "Foo1,Foo2,Foo3,Foo4,Foo5,Foo6,Ping Pong\n" +
"2016-02-29,1437.530029,1445.839966,1433.77002,1436.930054,34016300,1436.930054\n" +
"2016-02-25,1431.439941,1431.439941,1421.280029,1426.97998,78076500,1426.97998\n" +
"2016-02-24,1430.459961,1432.430054,1417.449951,1419.790039,29049900,1419.790039\n";
我该如何将其转换为
List<Model>
呢?public class Model
{
public string Foo1 { get; set; }
public string Foo2 { get; set; }
public string Foo3 { get; set; }
public string Foo4 { get; set; }
public string Foo5 { get; set; }
public string Foo6 { get; set; }
public string Ping_Pong { get; set; }
}
注意原始CSV文件中的头部信息
我尝试使用CsvHelper,但因为它需要流而不是字符串,所以没有成功。我还尝试转换解析,但失败了。
编辑对我来说是否要使用CsvHelper无关紧要,最终我想将CSV文件转换为List<Model>
我该如何做到这一点?
string
转换为Stream
。https://dev59.com/o3I-5IYBdhLWcg3wZ3UR - juharr