Solved

Copy csv file to array

Posted on 2008-10-04
2
335 Views
Last Modified: 2008-10-06
I am trying to copy a csv file to a vb array with the code below.  However this csv file has over 180,000 rows of data and I get an overflow error.  How can I copy the file to an array?
Open App.Path & "\test.csv" For Input As #1

   Input #1, numRows, numCols, col1Text, col2Text

   ReDim DJData(numRows, numCols) As Double

   

   For i = 1 To numRows

      Input #1, DJData(i, 1), DJData(i, 2)

   Next i

   

   Close #1

Open in new window

0
Comment
Question by:coderblues
2 Comments
 
LVL 14

Accepted Solution

by:
raja_ind82 earned 500 total points
ID: 22643732
0
 
LVL 45

Expert Comment

by:aikimark
ID: 22644796
What are col1Text, col2Text?  Are col1Text, col2Text only on the first row?

Do you have just two columns?  If so, why do you need numCols?

Are all the data in second through the last record numeric data?

Dim i As Long

Dim j As Long

Dim DJData() As Double
 

   Open App.Path & "\test.csv" For Input As #1

   Input #1, numRows, numCols, col1Text, col2Text

   ReDim DJData(1 To numRows, 1 To numCols)

   

   For i = 1 To numRows

      For j = 1 To numCols

         Input #1, DJData(i, j)

      Next j

   Next i

   

   Close #1

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 71
vb6 connector to SQL Server 2 34
Recommendation vb6 to vb.net or others 14 112
Excel Automation VBA 19 38
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now