Skip to content

QuickCSVLoad

Cinchoo edited this page Jun 11, 2017 · 17 revisions

Loading CSV file

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

Load using iterator

foreach (var e in new ChoCSVReader("Emp.csv"))
    Console.WriteLine(e.ToStringEx());

Load using loop

var reader = new ChoCSVReader("Emp.csv");
object rec = null;
 
while ((rec = reader.Read()) != null)
    Console.WriteLine(rec.ToStringEx());

Load using POCO object

public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
}
foreach (var e in new ChoCSVReader<Employee>("Emp.csv"))
    Console.WriteLine(e.ToStringEx());
Clone this wiki locally