B
bulldawgfan12000
Thanks for reading. Excel 2003. I'm trying to use the code below
(not mine) to read a huge text file, which I believe comes from UNIX,
into multiple sheets. The text file is 25mb and is ~500,000 lines
when viewed in EditPad (notepad doesn't format it right) so I am
pretty sure it is using *LF* only. There are no other delimiters in
the file what so ever. It's not fixed width either.
VBA Help says that "The Line Input # statement reads from a file one
character at a time until it encounters a carriage return (Chr(13)) or
carriage return-linefeed (Chr(13) + Chr(10)) sequence."
So, why is this not working? It's basically reading the whole file as
one line and therefore gets an error once the "InStr" gets to ~25
million.
Right now, I am planning on reading the file into multiple sheets and
then saving those sheets back out as individual text files. This is
because I've already written a LONG program to pull each in as fixed
width and manipulate/format the data back the way I need it to be sent
to an Access Database. That is, after I had manually "split" the
files using Edit Pad.....
Thanks all, this board has invaluable so far in this project; I just
couldn't find any posts re: this exact subject.
Do While Not EOF(5)
iSh = (I / MaxSize) + 1
lL = I Mod MaxSize
Line Input #5, strLine
If Right(strLine, 1) <> sDelim Then
strLine = Trim(strLine) & sDelim
End If
J = 0
Do While Len(strLine) > 1
iLen = InStr(strLine, sDelim)
Worksheets("Sheet" & iSh).Offset(lL, J).Value = _
Trim(Left(strLine, iLen - 1))
strLine = Trim(Right(strLine, Len(strLine) - iLen))
J = J + 1
Loop
I = I + 1
Loop
(not mine) to read a huge text file, which I believe comes from UNIX,
into multiple sheets. The text file is 25mb and is ~500,000 lines
when viewed in EditPad (notepad doesn't format it right) so I am
pretty sure it is using *LF* only. There are no other delimiters in
the file what so ever. It's not fixed width either.
VBA Help says that "The Line Input # statement reads from a file one
character at a time until it encounters a carriage return (Chr(13)) or
carriage return-linefeed (Chr(13) + Chr(10)) sequence."
So, why is this not working? It's basically reading the whole file as
one line and therefore gets an error once the "InStr" gets to ~25
million.
Right now, I am planning on reading the file into multiple sheets and
then saving those sheets back out as individual text files. This is
because I've already written a LONG program to pull each in as fixed
width and manipulate/format the data back the way I need it to be sent
to an Access Database. That is, after I had manually "split" the
files using Edit Pad.....
Thanks all, this board has invaluable so far in this project; I just
couldn't find any posts re: this exact subject.
Do While Not EOF(5)
iSh = (I / MaxSize) + 1
lL = I Mod MaxSize
Line Input #5, strLine
If Right(strLine, 1) <> sDelim Then
strLine = Trim(strLine) & sDelim
End If
J = 0
Do While Len(strLine) > 1
iLen = InStr(strLine, sDelim)
Worksheets("Sheet" & iSh).Offset(lL, J).Value = _
Trim(Left(strLine, iLen - 1))
strLine = Trim(Right(strLine, Len(strLine) - iLen))
J = J + 1
Loop
I = I + 1
Loop