CSVReader - a simple open source C# class library to read CSV data


CSVReader is a simple, lightweight open source C# class library to read CSV data from text files and strings. To use it, simply download the latest version and add it to your project, either as a compiled DLL (it will build in any version of Visual Studio 2008) or as source.

Download: CSVReader source v1.0.2

If you want to include CSVReader directly in your source code, just download CSVReader.cs and StringConverter.cs and add them to your C# project.


  1. Download the source CSVReader source code to a folder. (The easiest way to do this is to install Subversion and check it out.)
  2. Open Visual Studio and create a new Windows Forms Application project.
  3. Select File >> Add >> Existing Project and navigate to CSVReader.csproj. Add it to the project.
  4. Right-click on "References" in your test project, select "Add References", click the Projects tab, and select the CSVReader project.
  5. Drag a DataGridView control out of the toolbox onto your form. Make sure it's named dataGridView1 and that its Dock property is set to Fill.
  6. Add using Com.StellmanGreene.CSVReader; to the top of the form code in Form1.cs.
  7. Replace the form's constructor with this code:
    public Form1()
        OpenFileDialog dialog = new OpenFileDialog();
        dialog.Filter = "CSV Files (*.csv)|*.csv";
        if (dialog.ShowDialog() == DialogResult.OK)
            DataTable table = CSVReader.ReadCSVFile(dialog.FileName, true);
            dataGridView1.DataSource = table;
  8. Run your program. When it starts, it will pop up a dialog box. Navigate to a valid CSV file with a header row and click OK. The contents of the file will be loaded into the data grid on the form.
You can see lots of example code in the source code for the unit tests. CSVReader can read CSV data:


This source code is released under the BSD License.

Revision history