Last updated at 7:06 am UTC on 28 June 2016
As of 2016 use the following package
by Arvi Bryant
or directly work with findTokens:escapedBy: (CSV parsing).
Can anyone point to an up-to-date source for these methods?
Here are a couple of small methods to assist in working with CSV (Comma-Separated Values) files.
The first method is on String, and will take a CSV line and transform it into an ordered collection of substrings.
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:
rows _ OrderedCollection new.
file _ StandardFileStream fileNamed: 'someFileName.csv'.
file linesDo: [:line| rows addLast: line csvSubstrings].