Reading in .csv files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick Hoare

    #1

    Reading in .csv files

    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


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: Reading in .csv files

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

    There are actually three Split functions in VB.NET:

    Use Microsoft.Visua lBasic.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.S plit 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.Reg ularExpressions .RegEx.Split to split based
    on matching patterns.

    Hope this helps
    Jay


    "Nick Hoare" <hoarsepower@ho tmail.com> wrote in message
    news:tQk2b.6160 7$bo1.33843@new s-server.bigpond. net.au...[color=blue]
    > 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[/color]
    in[color=blue]
    > 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[/color]
    take[color=blue]
    > note of the VB6 examples i found or start from scratch?
    >
    >
    > Any help or reference links is greatly appreciated!
    >
    > Regards
    > Nick Hoare
    >
    >[/color]


    Comment

    • Andrew Hull

      #3
      Re: Reading in .csv files

      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
      "Nick Hoare" <hoarsepower@ho tmail.com> wrote in message
      news:tQk2b.6160 7$bo1.33843@new s-server.bigpond. net.au...[color=blue]
      > 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[/color]
      in[color=blue]
      > 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[/color]
      take[color=blue]
      > note of the VB6 examples i found or start from scratch?
      >
      >
      > Any help or reference links is greatly appreciated!
      >
      > Regards
      > Nick Hoare
      >
      >[/color]


      Comment

      Working...