Results 1 to 2 of 2

Thread: Visual Basic StreamReader - Importing a csv file into an array

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2020
    Posts
    5

    Visual Basic StreamReader - Importing a csv file into an array

    Hi all

    I have a set of data in csv format, numbers only. It is 2 columns x 111 (varying length) array. It will always be 2 columns.

    I am struggling to get the data into an array to manipulate it further.

    Can anyone help how I can get the 2 column csv file into a double array?

    I have got it working into a textbox using txt.Text = StreamToDisplay.ReadToEnd, but struggling with getting it into an array

    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Visual Basic StreamReader - Importing a csv file into an array

    Start by calling Fiile.ReadAllLines. That will read the lines of the file into a 1D array. That will tell you how many "rows" you need in your 2D array so that you can create it. You can then use a For loop to access each line, split it and populate the corresponding "row" of the 2D array with the numeriic values. No, I'm not going to write an "example" for you. Follow the instructions as best you can and then, if you encounter a specific issue along the way, ask about that specifically.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width