CSV Methods - DEAD LINKS
Last updated at 1:16 am UTC on 17 January 2006
Can anyone point to an up-to-date source for these methods?
Try: http://web.archive.org/web/*/http://nest.swiki.net/.uploads/String-csvSubstrings.st
Here are a couple of small methods to assist in working with CSV (Comma-Separated Values) files.
String-csvSubstrings.st
The first method is on String, and will take a CSV line and transform it into an ordered collection of substrings.
SequenceableCollection-asCSVLine.st
The second method is on SequenceableCollection (i.e., will work with OrderedCollection and Array) and will convert the objects in that collection into a CSV line.
Some code to read a CSV file:
|file rows|
rows _ OrderedCollection new.
file _ StandardFileStream fileNamed: 'someFileName.csv'.
file linesDo: [:line| rows addLast: line csvSubstrings].
rows inspect.
Chris Cunningham