1 class:: SemiColonFileReader
2 summary:: file reader for semi-colon separated data
7 SemiColonFileReader reads semi-colon delimited files into 2D arrays.
9 For tab delimited files use link::Classes/TabFileReader::. For comma-separated files use link::Classes/CSVFileReader::. For space-delimited files, or custom delimiters, use link::Classes/FileReader::.
16 f = File("SemiColonTest.sc", "w");
18 "Some semi-colon delimited data;
28 // open file, read and put strings into array, close file.
29 x = SemiColonFileReader.read("SemiColonTest.sc").postcs;
31 // can skip empty lines:
32 x = SemiColonFileReader.read("SemiColonTest.sc", true).postcs;
34 // can skip blank entries caused by multiple commas:
35 x = SemiColonFileReader.read("SemiColonTest.sc", true, true).postcs;
37 // do file open/close by hand if you prefer:
38 f = File("SemiColonTest.sc", "r"); f.isOpen;
39 t = SemiColonFileReader(f);
44 // write a test file with numbers:
45 f = File("SemiColonTestNum.sc", "w");
47 (1..10).do { |n| f.write(n.asString ++ ";"); };
51 x = SemiColonFileReader.read("SemiColonTestNum.sc").postcs;
52 x.collect(_.collect(_.interpret)); // convert to numbers.
54 // or you can do it immediately:
55 x = SemiColonFileReader.readInterpret("SemiColonTestNum.sc").postcs;
58 // write a test file with numbers:
59 f = File("SemiColonTestNum.sc", "w");
62 f.write(n.asString ++ if (n % 10 != 0, $;, Char.nl)); };
67 x = SemiColonFileReader.readInterpret("SemiColonTestNum.sc").postln;