Using Seek to read csv file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was taking the data in a csv file and importing it to an array in vba.

The csv file has 1000 scenarios with 361 time intervals in each scenario -
so there are 3,610,000 total rows. I want the array to be able to grab a
scenario based on an input. So my first attempt was to skip the first
scenarios until I got to the scenario that I wanted, then write to the array
for 360 times.

So if I wanted to pick up scenario number '34' I would write

For i = 1 to (34 * 361)
input #1, temp 'does nothing
Next i

For i = 1 to 360
input #1, Array(i)
next i

But can you use the "Seek" function to skip ahead to scenario 34 then start
reading. Because the way I have it written seems like a waste because I
start reading from the beginning each time - and I have to run a lot of
scenarios so I need it to be as fast as possible.

Thanks for your help on this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top