Skip to content

QuickCSVLoad

Cinchoo edited this page Apr 7, 2023 · 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)

Id,Name
1,Tom
2,Carl
3,Mark

Load using iterator

foreach (dynamic e in new ChoCSVReader("Emp.csv").WithFirstLineHeader())
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Load using loop

var reader = new ChoCSVReader("Emp.csv").WithFirstLineHeader();
dynamic e;
 
while ((e = reader.Read()) != null)
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

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").WithFirstLineHeader())
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Please visit below article for detailed walk-through of CSV reader

Cinchoo ETL - CSV Reader