Import CSV file to strongly typed data structure in .Net

c#, csv, file, import, vb.net

Solution

Microsoft's TextFieldParser is stable and follows RFC 4180 for CSV files. Don't be put off by the `Microsoft.VisualBasic` namespace; it's a standard component in the .NET Framework, just add a reference to the global `Microsoft.VisualBasic` assembly.

If you're compiling for Windows (as opposed to Mono) and don't anticipate having to parse "broken" (non-RFC-compliant) CSV files, then this would be the obvious choice, as it's free, unrestricted, stable, and actively supported, most of which cannot be said for FileHelpers.

See also: How to: Read From Comma-Delimited Text Files in Visual Basic for a VB code example.

Problem

What's the best way to import a CSV file into a strongly-typed data structure?

Original source

Related problems