Click here to Skip to main content
13,141,286 members (80,890 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 27 Jan 2017

Cinchoo ETL - Quick Start: Reading CSV File

, 18 Jun 2017
Rate this:
Please Sign up or sign in to vote.
Quick start tutorial to read CSV file

1. Introduction

ChoETL is an open source ETL (extract, transform and load) framework for .NET. It is a code based library for extracting data from multiple sources, transforming, and loading into your very own data warehouse in .NET environment. You can have data in your data warehouse in no time.

This article talks about reading CSV file using ChoCSVReader component offered by ChoETL framework. It is a simple utility class to extract CSV data from file / source.

To learn more about Cinchoo ETL - CSVReader, please visit the CodeProject article here.

2. Requirement

This framework library is written in C# using .NET 4.5 Framework.

3. How to Use

3.1 Sample Data

Let's begin by looking into a simple example of reading the below CSV file having 4 columns.

Listing 1. Sample CSV data file

1732,Tom Perez,435.00,05/11/2002
5541,Pedro Gomez,12342.30,06/02/2004
1122,Mark Politti,0.00,01/02/2000
1924,Pablo Ramirez,3321.30,11/24/2002

The first thing to do is to install ChoETL. To do this, run the following command in the Package Manager Console.

Install-Package ChoETL

Now, add ChoETL namespace to the program.

using ChoETL;

3.2 Quick Read - Zero Config Approach

This approach shows you how to consume CSV file without any mapping class.

Listing 2. Read CSV Files without mapping class

var engine = new ChoCSVReader("Customer.csv").WithFirstLineHeader();

// To Read 
foreach (dynamic cust in engine)
    Console.WriteLine("Customer Info:");
    Console.WriteLine(cust.CustId + " - " + cust.AddedDate);

3.3 Read with Mapping Class

This approach talks about reading CSV file using Mapping Class. Create a class which has properties with the same name of the column headings found in the CSV file. Below, you will find an example of a class which does this.

Listing 3. Mapping class

public class Customer
	public int CustId { get; set; }
	public string Name { get; set; }
	public decimal Balance { get; set; }
	public DateTime AddedDate { get; set; }

3.3 Create a ChoCSVReader for Read

Finally, create an instance of ChoCSVReader class and invoke the Read() method to read all the records or use foreach loop on it to iterate through the objects. Below, you will find an example of this.

Listing 4. Read CSV Files with mapping class

var engine = new ChoCSVReader<Customer>("Customer.csv").WithFirstLineHeader();

// To Read 
foreach (var cust in engine)
    Console.WriteLine("Customer Info:");
    Console.WriteLine(cust.Name + " - " +

For more information about Cinchoo ETL, please visit the below CodeProject article:


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170915.1 | Last Updated 19 Jun 2017
Article Copyright 2017 by Cinchoo
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid