[Newbies] Re: reading lines from textfiles on Linux

David Shaffer cdshaffer at acm.org
Tue May 16 15:38:35 UTC 2006


Charles D Hixson wrote:

>Charles D Hixson wrote:
>  
>
>>OK, lets try again, this code:
>>
>>    | fil lin n |
>>    Transcript cr; show: (SmalltalkImage current platformName).
>>    fil    :=    FileStream fileNamed: 'aising/data/technologies.csv' .
>>    Transcript cr; show: (fil    detectLineEndConvention).
>>    Transcript cr; show: 'LineEndConvention = '; show: fil
>>    detectLineEndConvention.
>>    fil  position: 0.
>>    n    :=    0.
>>    [fil atEnd] whileFalse:
>>    [ lin := fil nextLine.
>>      n := n + 1.
>>      Transcript cr; show: 'lin '; show: n; show: ' = '; show: lin.
>>    ].
>>     Transcript cr; show: 'normal end after '; show: n; show: ' lines'.
>>
>>results in this output:
>>
>>    unix
>>    nil
>>    LineEndConvention = nil
>>    lin 1 = 'technology'                                       
>>    'id'    'name'    'cost1'    'cost2'    'cost3'    'pre1'   
>>    'pre2'    'pre3'    'danger'    'typeName'    'typeValue'
>>    1    'Autonomous Vehicles'    40000    1000    0    27    16    0   
>>  
>>...
>>    41    'unknown'    1000000000    10000000000    0    41    0    0   
>>    0        0
>>
>>    normal end after 1 lines
>>
>>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.
>>  
>>    
>>
>Just in case I went back to a vanilla image...nothing imported from
>Squeak map, no classes defined by me.  Plain.  (Deleted all the images,
>changes, etc. and re-extracted from the tarball.)  This made no difference.
>
>_______________________________________________
>Beginners mailing list
>Beginners at lists.squeakfoundation.org
>http://lists.squeakfoundation.org/mailman/listinfo/beginners
>  
>
Charles,

I'm having a hard time following this thread.  Your problem seems
straightforward: You would like to read a LF separated file on a UNIX
platform.  You seemed to have studied the various streams and ended up
with CrLfFileStream.  So far everything seems fine.  I do this quite
often.  Maybe it isn't the "new way" with multi-byte characters and
whatnot.  I can't say since I'm still using Squeak 3.7 but I'm guessing
that you could get it to work.  If you send me (or post) the file you're
trying to process I would be happy to do the following:

a) Read it using CrLfFileStream on Squeak 3.8 full and report my experience
b) Look into the possibility of a bug in aformentioned class in light of
stream changes made in Squeak 3.8.

If I've missed the boat on this thread, please pardon mean.  Only had
time to skim it quickly.

David



More information about the Beginners mailing list