Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Read text file

Hi,
I'm reading a text file originating from Unix using the
Line Input #Filenumber statement. This goes haywire due
to the fact that each line in the file is terminated with
Chr(10), i.e. linefeed, only. Excel then reads the whole
file into one string as Chr(13) is missing. Anybody know
how to deal with this?
Any help appreciated.

jacob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Read text file

You could do something as below using the Input Funciton (not to be confused
with the Input Statement) to read the characters individually and when you
get to a LineFeed, tack on a Carriage Return before it. This procedure
replaces the old file with a new one that has the Carriage Returns inserted.

Sub Tester02()

Open sFile For Input As #1
Do While Not EOF(1)
sChar = Input(1, #1)
If sChar = vbLf Then sChar = vbCr & sChar
sString = sString & sChar
Loop
Close #1

Open sFile For Output As #1
Print #1, sString
Close #1

End Sub

HTH,
Shockley


"jacob" wrote in message
...
Hi,
I'm reading a text file originating from Unix using the
Line Input #Filenumber statement. This goes haywire due
to the fact that each line in the file is terminated with
Chr(10), i.e. linefeed, only. Excel then reads the whole
file into one string as Chr(13) is missing. Anybody know
how to deal with this?
Any help appreciated.

jacob



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Read text file

Hi,
Thx, this should work.
-----Original Message-----
You could do something as below using the Input Funciton

(not to be confused
with the Input Statement) to read the characters

individually and when you
get to a LineFeed, tack on a Carriage Return before it.

This procedure
replaces the old file with a new one that has the

Carriage Returns inserted.

Sub Tester02()

Open sFile For Input As #1
Do While Not EOF(1)
sChar = Input(1, #1)
If sChar = vbLf Then sChar = vbCr & sChar
sString = sString & sChar
Loop
Close #1

Open sFile For Output As #1
Print #1, sString
Close #1

End Sub

HTH,
Shockley


"jacob" wrote in message
...
Hi,
I'm reading a text file originating from Unix using the
Line Input #Filenumber statement. This goes haywire due
to the fact that each line in the file is terminated

with
Chr(10), i.e. linefeed, only. Excel then reads the

whole
file into one string as Chr(13) is missing. Anybody

know
how to deal with this?
Any help appreciated.

jacob



.

Reply
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
How to read all lines from a text file into cells C10:Cxxx ? Claudia d'Amato Excel Discussion (Misc queries) 1 September 22nd 09 01:11 PM
Data from exported file read as text, when edited becomes a # (pic Jarod Excel Discussion (Misc queries) 1 July 1st 09 02:21 AM
to read text tablimited file pol Excel Discussion (Misc queries) 2 May 27th 09 01:14 PM
How do you save an excel file to be read as IBM-type text file ? Dee Franklin Excel Worksheet Functions 2 October 10th 06 02:46 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"