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: 4
Default Line Input not finding Chr10 or 13

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 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

 
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
finding 10 smallest numbers from last 20 input handicapper Excel Worksheet Functions 8 May 3rd 10 02:29 PM
Countif for finding a Time input Meebers[_4_] Excel Worksheet Functions 4 April 14th 10 01:21 AM
Reads entire *.txt file into string opposed to a desired line by line input. ej_user Excel Programming 3 October 11th 04 07:15 PM
Finding Column based on input, then first empty row Charles Excel Programming 2 April 1st 04 07:56 PM
Finding Column based on input, then first empty row stevem[_2_] Excel Programming 0 April 1st 04 07:01 PM


All times are GMT +1. The time now is 12:13 AM.

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"