On success, the function returns nothing (void), the call back function have been called for every line.
std.std.exception.Exception. on failure to correctly parse a line. std.std.file.FileException. on I/O failures.
// Load a text file with three numeric columns, // Store the tuple in an array // (NOTE: this is a naive, inefficient way to populate an array, see NOTES) alias Tuple!(int,int,int) T; T[] t; tabular!( T, // The number and types of the (expected) fields in the file delegate(x) { t ~= x; }, // for each line read, call this function. X will be of type T. '\t' // The delimiter (default = TAB) )("file.txt"); // The file name to read.
// Load a text file with three numeric columns, // Use the second column as a KEY and the third column as the VALUE. alias Tuple!(int,int,int) T; int[int] data; tabular!( T, // The number and types of the (expected) fields in the file delegate(x) { // for each line read, call this function. X will be of type T. data[x[1]] = x[2] ; }, '\t' // The delimiter (default = TAB) )("file.txt"); // The file name to read.
Notes: $(OL
$(LO )
TODO: Make this an InputRange
Loads a delimited text file, line-by-line, parses the line into fields, and calls a delegate/function for each line.