HI All,
Request your help, in the below code the output from main
(writeln(columns[0][])) function is like ["Miller", "John",
"Millman", "Zsuwalski"] where as the writeln(col[0]) from the
function master is as below, so how do i get the output same as
in main from the function master.
CSV file content
Miller, America, 23
John, Africa, 42
Output from function master
Miller
America
23
alias ColumnTypes = AliasSeq!(string, string, int);
auto readData(string fName) {
auto uFile = File(fName, "r");
Tuple!( staticMap!(Array, ColumnTypes) ) res;
foreach (record;
uFile.byLineCopy().joiner("\n").csvReader!(Tuple!ColumnTypes)) {
foreach(i, T; ColumnTypes) { res[i].insert(record[i]); }
}
return res;
}
auto master(T)(ref Array!T col) {
writeln(col[0]); // The output2 is Miller
// America
// 23
}
void main() {
auto fName =
"C:\\Users\\bheev1\\Desktop\\Current\\Script\\Others\\TColRead.csv";
auto columns = readData(fName);
writeln(columns[0][]); // The output1 is ["Miller", "John"]
foreach(i, ColT; ColumnTypes) {
dictcompress(columns[i]);
}
}
From,
Vino.B