View Single Post
  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

How about if someone else pastes it in a message?

Jim named his copy: ParseLongFile.vbs
(the .VBS is important)

'---------------------------------------------------------------

Dim fso, fileSource, fileDest
Dim fileSourceNoExt,fileSourceExt
Dim lineCount, txtLine
Dim wsh, tempFile
Dim fileCount, dotPos

Set fso = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("WScript.Shell")
''Set sh = CreateObject("Shell.Application")

tempFile = InputBox("Enter the full path and name of file", _
"Long Text File Parser")

''The following would not return a file, just a folder object,
'' even tho with the 16896 it displays files
''tempFile = sh.BrowseForFolder(0, "Select a Folder", 16896, "c:\")

If tempFile < "" Then
If fso.FileExists(tempFile) Then
dotPos = InStrRev(tempFile,".")
If dotPos 0 Then
fileSourceNoExt = Left(tempFile, dotPos-1)
fileSourceExt = Mid(tempFile,dotPos)
Else
fileSourceNoExt = tempFile
End If
Set fileSource = fso.OpenTextFile(tempFile)
Do While fileSource.AtEndOfLine < True
If lineCount = 0 Then
FileCount = FileCount + 1
Set fileDest = fso.CreateTextFile(fileSourceNoExt & FileCount _
& fileSourceExt, True)
End If
txtLine = fileSource.ReadLine
fileDest.WriteLine txtLine
lineCount = lineCount + 1
If lineCount = 65536 Then
fileDest.Close
lineCount = 0
End If
Loop

fileSource.Close

wsh.Popup "Done!", 1, "Long Text File Parser"
Else
wsh.Popup "Source file not found", 2, "Long Text File Parser"
End if
End If

Max wrote:

attached a VBS script that I wrote to do that.


Was unable to save it, Jim ..
Could you paste it in the message itself ?
Thanks
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Jim Rech" wrote in message
...
I don't believe Chip's routines is designed to handle files beyond 64K

rows.
Another approach is to pre-parse the file into several 64k row files.

Copy it to your desktop and
double-click it to run it.

--
Jim Rech
Excel MVP
"Roy Lynn" <Roy wrote in message
...
| In Excel: If I know a file has 147,000 records, but Excel will only load
| 65,000, how do I get to the rest of the file?


--

Dave Peterson