[Newbies] Re: reading lines from textfiles on Linux

Klaus D. Witzel klaus.witzel at cobss.com
Tue May 16 16:56:14 UTC 2006


Hi Charles,

apologies if you felt that my questions where tough, I only wanted to know  
what your system says (yes, I've read your subject line, it mentions  
linux).

Be assured that, when you always post your whole data output, this is NOT  
useful at all; the first and the last line, sepeated by a comment of  
your's, would have served the purpose.

O.K. now we have seen that #detectLineEndConvention responds nil. This is,  
according to the implementation in 3.8-6665, not possible, since this  
method either returns LineEndDefault (a class variable, assigned  
unconditional) or one of the constant literals in this methods. But this  
holds only for CrLfFileStream, not for MultiByteFileStream. Have you tried  
with CrLfFileStream?

Next question: when you browse the method #detectLineEndConvention and in  
that pane select the class variable LineEndDefault and do a print-it, what  
does that show?

Charles, in your other posting you said that using a fresh copy of the  
plain image made no difference. When you use the Squeak File List browser  
(alt-L or ctrl-L with capital L) and view your file and then in the text  
pane's context menue ask for 'view as hex', can you confirm that this  
Smalltalk program can see and visualize your line ends?

I'm sorry this thread got a bit long. But I try to help, if that helps you.

Here's what I was forced to do for processing line-ends from a Http  
document (this is an online data source and you can try yourself). AFAIK  
Squeak's Http streams are transparent to cr's lf's (therefore my code  
below). You can put any file stream or string into it.

/Klaus

--------------
  | aCharStream tokens |

	aStringOrStream := 'http://mat.gsia.cmu.edu/COLOR/instances/myciel3.col'  
asUrl retrieveContents content.
	aCharStream := aStringOrStream isStream
				ifTrue: [aStringOrStream]
				ifFalse: [(RWBinaryOrTextStream
						with: (aStringOrStream replaceAll: Character lf with: Character cr))  
reset].
	[aCharStream atEnd]
		whileFalse: [(tokens := aCharStream nextLine) size > 1 ifTrue:  
[Transcript cr; show: tokens]
			].
	Transcript endEntry
--------------

On Tue, 16 May 2006 16:12:40 +0200, Charles D Hixson  
<charleshixsn at earthlink.net> wrote:
...very big snip...
> Note the: "normal end after 1 lines" at the end.  Note the only the
> first line of the response includes the preface "lin # =" that the code
> is supposed to be generating on a per line basis.  Note the
> "LineEndConvention = nil".  This time I didn't elide any of the output,
> but the stuff in the middle is probably ignorable, it's only the start
> and the end of the result that are significant.




More information about the Beginners mailing list