[Newbies] Re: reading lines from textfiles on Linux
Charles D Hixson
charleshixsn at earthlink.net
Tue May 16 15:32:52 UTC 2006
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.
More information about the Beginners
mailing list