Results 1 to 4 of 4

Thread: .csv file into an array

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    11

    .csv file into an array

    Help...

    I have a large .CSV file containing numbers only.

    I can import it into a VB text box to get a string of numbers like:
    2,45,623,55,3,6,,,,etc.

    However I need to break the data up and put it into an array so it looks like:

    2,45,623
    55,3,6
    ,,,,,etc

    Any Ideas?

  2. #2
    Junior Member
    Join Date
    May 2002
    Location
    Leicester study in leeds
    Posts
    28
    hello

    Might be a good idea to create a import spec and pass all numbers into a table. From this you could create a query to get the desired results and thus output them to your list box!

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    This should do the trick !
    Code:
    Dim strCSVFileText As String
    Dim straryCSVFileLines() As String
    Dim intCounter As Integer
    
    intCounter = 0
    
    Open "C:\TestCSVFile.csv" For Input As #1
    
        Do While Not EOF(1)
            
            ReDim Preserve straryCSVFileLines(intCounter)
            
            Line Input #1, straryCSVFileLines(intCounter)
    
            intCounter = intCounter + 1
    
        Loop
    Close #1

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Addicted Member darrenl's Avatar
    Join Date
    Jul 2000
    Location
    Portsmouth, UK
    Posts
    148
    This is a good web site for quick code. They have just added some parse CSV code.
    http://www.xbeat.net/vbspeed/index.htm
    Dazzer

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