[Newbies] Parsing and splitting file contents

r00t uk r00tuk at gmail.com
Sat Aug 29 13:48:02 UTC 2009


Ok, I am new to smalltalk.  I have tried browsing and searching for methods
related to parsing and splitting file contents based on a delimiter, but I
am not having much success. :(  Old google is not helping either so I can
only assume that I am missing something "obvious".

I am reading a tab delimited file into a string.  I want to iterate through
this string and split by tab, or any other defined value (, . | # tab, cr,
etc.), delimiter into substrings which are assigned to a Collection (Array,
Dictionary, Bag, etc.), or instant variables.

I was hoping there was going to be something like:

Bag := FileStream collect: [:x | split: crlf].
Dictionary := Bag collect: [:x | split: tab].

Does that make any sense?  Basically create Bag with contents of FileStream
split by crlf and then split Bag elements by tab into key value pairs.

Again, I am surprised by the lack of examples demonstrating to newbies how
to perform basic operations such as this.  I know it is not the smalltalk
way of learning, but it does raise the bar for making progress.  The
language may be easy, but finding which methods to use to solve problems is
a bit laborious.

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20090829/819223c9/attachment.htm


More information about the Beginners mailing list