Solved

Copy csv file to array

Posted on 2008-10-04
2
338 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 70
How to compare ms sql hashbytes results within vb6 5 74
Macro Excel - Multiple If conditions 2 72
Excel Automation VBA 19 70
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 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