C# CSV Import

An old topic, I agree. Unfortunately we still can’t forget about CSV files and I see so many questions popping up on forums and especially on my blog related to this topic. Not every company features APIs or XML files yet, so it’s always nice to be comfortable with CSV Readers or Libraries.

First of all: Don’t write your own CSV Parser! No matter if it’s a C# CSV Import or VB.NET. There are so many libraries, frameworks, etc. – you really don’t have to reinvent the wheel once again. It’s not just about using String.Split(“,”), you need to care for much more nasty stuff. Fortunately other people already went through the headaches for you!

So what to do? Use FileHelpers Library 2.0! Instead of calling array items by writing myarray[3] you can even use e.g. mycart.ID now, isn’t that beautiful? Here’s a little code example:

It won’t get easier than that. I use it in several ASP.NET Projects and best of all: It’s free! Check it out and thanks to Marcos for creating it: FileHelpers 2.0. You will find tons of examples for reading and writing CSV Files.