Data Transformation

C# CSV Reader

C# CSV Reader is the fast, easy to use library for all your file reading needs. It is designed as a .NET library that you can add to your .NET solution and get parsing within minutes. Files are still a popular way of exchanging data, and this library will allow you to read a variety of different formats in a breeze, saving you the time of developing and debugging from scratch. A robust, tried and tested technology you can rely on.

  • Saves you time
  • Get up and running within minutes
  • Ask questions in the forums if you need help
  • Sample code to get you started
  • Delimited file reader
  • Fixed width file reader
iconUnlock the possibilities

C# Data Reader is a no fuss library that is quick to deliver results. Browse around our documentation for demo code. Simply drop in the library, reference it, and you are all set to go! Choose some code from the samples, that is most similar to your use case, and tweak it to cater to your needs.

iconTools anyone can use

C# Data Reader supports a number of different formats that you may be using in your organization. In general, flat files contain a number of columns which are either seperated by a specified character or where each column is a set number of chars wide. A CSV file, or Comma Delimited File, is where the comma is used to specify the end of each column. However, with the Delimited Reader, any delimiter you may choose is supported. With the fixed width file reader, simply specify the column widths before reading.

iconEasily affordable

Give it a try now! We have a trial version that does not expire. Available in the Downloads area.

Code Snippets


Reading and writing from a delimited text file

This example assumes you have a file on your system called C:\data.csv which is simple text file containing data consisting of comma seperated values.

//Instanciate the DelimitedFileReader by passing in the path:
var reader = new DelimitedFileReader(@"C:\data.csv");

//Then one can read in the data in the following formats.
//XML string:
string xml = reader.ReadAsXml();

//.NET DataTable:
DataTable dataTable = reader.ReadAsDataTable();

//Or to convert to a strongly typed list of a custom class you created in your project:
List<MyClass> list = reader.ToList<MyClass>()

Or, open a Fixed Width File

With a fixed width file you need to tell it how many columns to expect and how many characters wide each column is. In this example we are opening a file with five columnes, each being 10 characters wide.

var reader = new FixedWidthFileReader(@"C:\data.txt""10,10,10,10,10");
var table = reader.ExecuteDataTable();

How to save your data into a CSV file:

var writer = new DelimitedFileWriter(table);
writer.WriteToFile(@"C:\data.csv");

Saving as Fixed Width file

Tell the FixedWidthFileWriter how many columns to designate for each column. This can be passed in explicitly, or in this example we are using fuzzy logic to work out the column widths for us, based on existing data:

var writer = new FixedWidthFileWriter(table);
writer.AutoSetColumnWidths();
writer.WriteToFile(@"C:\data.txt");

Opening a CSV file and saving the output as an XML file is really easy!

var reader = new DelimitedFileReader(@"C:\data.csv");
var xml = reader.ExecuteXml();
File.WriteAllText(@"C:\data.xml", xml);
Simple
Buy Now
  • Single domain
  • Single server
  • Single organization
  • Covers intranet hosting


corporate license$89
Multiple Sites
Buy Now
  • Any number of domains
  • Single server
  • Single organization
  •  


corporate license$199
Cloud
Buy Now
  • Any number of domains
  • Any number of servers
  • Single organization
  • Covers cloud hosting


corporate license$299
Commercial Product
Buy Now
  • Any number of domains
  • Any number of servers
  • Any number of organizations
  • Allows you to include library in your packaged commercial product
royalty free license$999
*After purchasing please allow us up to 24 hours to send you your new license file.
**Or alternively for use personal / development download a trial version which does not expire:
Download Trial!

Downloads

The following are a list of our latest builds.

Version 1.0.0

Download - Trial Version
*Please note that this trial does not expire - use as long as you like.
Get in touch

Please try to search through or post on the Forums first before asking a question, and if you are not able to find anything there to help you, then feel free to drops us a line.