VB.NET || How To Parse A Delimited CSV File Using VB.NET

Print Friendly, PDF & Email

The following is a module with functions which demonstrates how to parse a delimited CSV file using VB.NET.

The function demonstrated on this page uses FileIO.TextFieldParser to parse values in a CSV file.

This function parses a CSV file and returns its results as a List. Each List index represents a line in the CSV file, with each item in the list representing a record contained on that line.

1. Parse CSV File

The example below demonstrates the use of ‘Utils.ParseCsv‘ to parse a CSV file and return its results as a List.

The optional function parameter allows you to specify the delimiters. Default delimiter is a comma (,).

Sample CSV used in this example is the following:

2. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!

3. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

Was this article helpful?
👍 YesNo

Leave a Reply