?
Solved

Copy csv file to array

Posted on 2008-10-04
2
Medium Priority
?
398 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 1500 total points
ID: 22643732
0
 
LVL 47

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

569 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