Reading in .csv files

  • Thread starter Thread starter Nick Hoare
  • Start date Start date
N

Nick Hoare

Hi, i am new to VB.Net and really enjoying the trip so far =)

However I have this problem:
I was wondering if anyone is familiar with how to go about reading in an
Excel ".csv" file? I had a search on the internet and found some VB6 code
examples, but i don't think VB6 code is the same as VB.Net is it?

I basically need to read the file in, storing the data (which is arranged in
columns) into a 2Dimensional array.
From there i want to write that data to a database table (most likely
Access) for permanent storage. Any future oeprations on the data (such as
search, edit) will reference the database table i wrote to.

I am familiar with using things like a StringTokenizer in Java, loops and
reading file in, but what do we have available in VB.Net? And should i take
note of the VB6 examples i found or start from scratch?


Any help or reference links is greatly appreciated!

Regards
Nick Hoare
 
Nick,
The closest thing to StringTokenizer in .NET is String.Split.

There are actually three Split functions in VB.NET:

Use Microsoft.VisualBasic.Strings.Split if you need to split a string based
on a specific word (string). It is the Split function from VB6.

Use System.String.Split if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter.

Alternatively use System.Text.RegularExpressions.RegEx.Split to split based
on matching patterns.

Hope this helps
Jay
 
Hi Nick,

Can you save the data in the excel file as XML, if you can you can read it
directly into a data adapter using the ReadXML function.

Cheers
Andrew
 
Back
Top