LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default load/parse large text file

I have a data file that I'm importing into Excel (starts as a VMS report
that is dumped into the body of an outlook message, which is then saved as a
text file). I parse it based on fixed width columns (no delimiter) the same
code is used for several different files, so the parse widths are stored in
an array.

When the file was smaller, it was plenty fast- but now the file has grown to
13MB, and it takes many minutes to import. I suspect there is a better way.
Right now I'm opening the file, grabbing each line, parsing it, then pasting
it to the worksheet (code below).

Can someone recommend the best practice to do this as quickly as possible?
I've already got calculations set to manual, and screenupdating to false. I
was considering loading the entire file first, then parsing each line in
memory, then pasting all the lines, but while that groups like operations
together, I wasn't sure how it would save time if all of the same operations
were still being done a line at a time.

Thanks!!
Keith

Open LongFN For Input As #1
Do While Not EOF(1)
Line Input #1, LineofText
If Len(LineofText) 3 Then
rw = rw + 1
' now parse LineofText according to the column
widths and
' put the values in an array.
For j = 1 To 30
ParseStart = TotalFileArray(WhichFile, j)
ParseEnd = TotalFileArray(WhichFile, j + 1)
If ParseEnd 0 Then
TotalDataArray(WhichFile, j, rw) =
Trim(Mid(LineofText, ParseStart, ParseEnd - ParseStart))
ConvertCol (j)
mywrksht.Range(Usecol & Trim(Str(rw))).Value
= TotalDataArray(WhichFile, j, rw)
End If
Next
End If
Loop
Close #1 'Close the file




 
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
load a CSV file and have it take all fields as text cj Excel Discussion (Misc queries) 5 March 29th 07 02:24 PM
How to parse data in text file sifar Excel Programming 4 October 8th 05 01:50 AM
Can I load text file into Excel seting field delimter using cmd li Tim Excel Discussion (Misc queries) 0 April 19th 05 01:55 AM
Load text file and write back sanjay Excel Programming 1 May 26th 04 03:28 AM
Parse Text File John[_62_] Excel Programming 5 October 22nd 03 02:50 PM


All times are GMT +1. The time now is 02:57 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"