2 summary:: file reader for tab separated data
7 TabFileReader reads tab/return delimited files into 2D arrays.
9 For semi-colon-delimited files use link::Classes/SemiColonFileReader::. For comma-separated files use link::Classes/CSVFileReader::. For space-delimited files, or custom delimiters, use link::Classes/FileReader::.
16 f = File("TabDelTest.sc", "w");
18 "Some tab- delimited items in line 1
20 and then some more in line 3
27 // open file, read and put strings into array, close file.
28 x = TabFileReader.read("TabDelTest.sc").postcs;
30 // can skip empty lines:
31 x = TabFileReader.read("TabDelTest.sc", true).postcs;
33 // do file open/close by hand if you prefer:
34 f = File("TabDelTest.sc", "r"); f.isOpen;
40 // write a test file with numbers:
41 f = File("TabDelTestNum.sc", "w");
43 (1..10).do { |n| f.write(n.asString ++ Char.tab); };
47 x = TabFileReader.read("TabDelTestNum.sc").postcs;
48 x.collect(_.collect(_.interpret)); // convert to numbers.
50 // or you can do it immediately:
51 x = TabFileReader.readInterpret("TabDelTestNum.sc").postcs;
54 // write a test file with numbers:
55 f = File("TabDelTestNum.sc", "w");
58 f.write(n.asString ++ if (n % 10 != 0, Char.tab, Char.nl)); };
63 x = TabFileReader.readInterpret("TabDelTestNum.sc").postln;