![]() |
Array question
I have a macro that processes a text file, reading data one line at a time.
Originally I did 2 "passes" on the file, the first step merely established the number of lines in the file so that I could use a progress indicator on the next pass through the file where I did my actual processing. Then I got the bright idea that instead of opening and closing the file twice I only needed to do it once and could save considerable processing time. I would open the file, and pass each line to an arrayed variable. After establishing the mumber of lines I would then access the array data instead of opening the file again. To my surprise this ended up saving virtually no time at all. Can anyone explain this ? |
Array question
Perhaps reading a file is not as inefficient as you thought. If you are
filling the array fully, then reading the array, isn't this like reading the file twice? I am curious how much time difference there is between just reading the once vs reading it twice? For small files (< 100's of thousands lines), I would expect the difference to be barely noticeable. Bob "Steve Farrar" wrote in message ink.net... I have a macro that processes a text file, reading data one line at a time. Originally I did 2 "passes" on the file, the first step merely established the number of lines in the file so that I could use a progress indicator on the next pass through the file where I did my actual processing. Then I got the bright idea that instead of opening and closing the file twice I only needed to do it once and could save considerable processing time. I would open the file, and pass each line to an arrayed variable. After establishing the mumber of lines I would then access the array data instead of opening the file again. To my surprise this ended up saving virtually no time at all. Can anyone explain this ? |
All times are GMT +1. The time now is 05:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com