Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 921
Default Using Seek to read csv file

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default Using Seek to read csv file

Seek function returns a number that indicates where you are in the file.

Jeff wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have a read only xl file, I need it to be read and write drama queen Excel Discussion (Misc queries) 3 July 1st 06 12:25 AM
XCEL FILE REC'D AS READ ONLY -- HOW TO NOT BE "READ ONLY" billybob Excel Discussion (Misc queries) 1 February 13th 06 03:14 AM
Pasword protected Excel file encrypted, how do I read this file? jonesteam Excel Discussion (Misc queries) 2 December 12th 05 06:32 PM
How can a file be converted from Read-Only to Read/Write Jim in Apopka Excel Discussion (Misc queries) 2 November 19th 05 04:59 PM
"Unable to read file" error message when opening a Excel file that contains a PivotTable report. Tim Marsden Charts and Charting in Excel 2 October 15th 05 02:10 PM


All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"