-
Notifications
You must be signed in to change notification settings - Fork 141
QuickCSVLoad
Cinchoo edited this page Jun 11, 2017
·
17 revisions
To load CSV file, use ChoCSVReader component to parse it. Sample below shows how to load CSV file (Emp.csv)
1,Tom
2,Carl
3,Mark
foreach (var e in new ChoCSVReader("Emp.csv"))
Console.WriteLine(e.ToStringEx());
var reader = new ChoCSVReader("Emp.csv");
object rec = null;
while ((rec = reader.Read()) != null)
Console.WriteLine(rec.ToStringEx());
public class Employee
{
[ChoCSVRecordField(1)]
[Required]
public int Id
{
get;
set;
}
[ChoCSVRecordField(2)]
[DefaultValue("XXXX")]
public string Name
{
get;
set;
}
public override string ToString()
{
return "{0}. {1}.".FormatString(Id, Name);
}
}
foreach (var e in new ChoCSVReader<Employee>("Emp.csv"))
Console.WriteLine(e.ToStringEx());
©2017 Cinchoo Inc