SuperCollider CLASSES


file reader for comma separated data


CSVFileReader reads comma-separated text files into 2D arrays line by line.

For tab delimited files use TabFileReader. For semi-colon-delimited files use SemiColonFileReader. For space-delimited files, or custom delimiters, use FileReader.

Class Methods

Inherited class methods

Undocumented class methods


Instance Methods

Inherited instance methods


// write a test file:
f = File("", "w");
"Some,comma,delimited,items, in line 1

and then, some more, with several commas,,,, in line 3

    // open file, read and put strings into array, close file.
x ="").postcs;

    // can skip empty lines:
x ="", true).postcs;

    // can skip blank entries caused by multiple commas:
x ="", true, true).postcs;

    // do file open/close by hand if you prefer:
f = File("", "r"); f.isOpen;
t = CSVFileReader(f);, true).postcs;

// write a test file with numbers:
f = File("", "w");

(1..10).do { |n| f.write(n.asString ++ ","); };

x ="", true, true).postcs;
x.collect(_.collect(_.interpret));    // convert to numbers.

    // or do it immediately:
x = CSVFileReader.readInterpret("").postcs;

// write a test file with several lines of numbers:
f = File("", "w");

(1..100).do { |n|
    f.write(n.asString ++ if (n % 10 != 0, ",",; };

x = CSVFileReader.readInterpret("", true, true).postln;