SuperCollider CLASSES


file reader for space-delimited text files
Inherits from: Stream : AbstractFunction : Object


FileReader reads space-delimited text files into 2D arrays line by line.

For tab delimited files use TabFileReader. For semi-colon-delimited files use SemiColonFileReader. For comma-separated files use CSVFileReader.

Class Methods

Inherited class methods

Undocumented class methods


*new (pathOrFile, skipEmptyLines: false, skipBlanks: false, delimiter)

*read (path, skipEmptyLines: false, skipBlanks: false, func, delimiter, startRow: 0, skipSize: 0)

*readInterpret (path, skipEmptyLines: false, skipBlanks: false, delimiter, startRow: 0, skipSize: 0)

Instance Methods

Inherited instance methods

Undocumented instance methods








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

and then some more with several blanks     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 spaces:
x ="", true, true).postcs;

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

    // take letter "a" as delimiter:
x ="", true, true, delimiter: $a).postcs;

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

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

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

    // or do it immediately:
x = FileReader.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 = FileReader.readInterpret("", true, true).postln;