Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (28 sloc) 663 Bytes
use System.IO.File;
use Data.CSV;
class CsvData {
function : Main(args : String[]) ~ Nil {
file_out : FileWriter;
leaving {
if(file_out <> Nil) {
file_out->Close();
};
};
if(args->Size() > 0) {
file_name := args[0];
csv := CsvTable->New(FileReader->ReadFile(file_name));
if(csv->IsParsed()) {
csv->AppendColumn("SUM");
for(i := 1; i < csv->Size(); i += 1;) {
row := csv->Get(i);
sum := row->Sum(row->Size() - 1);
row->Set("SUM", sum->ToString());
};
};
output := csv->ToString();
output->PrintLine();
file_out := FileWriter->New("new-csv.csv");
file_out->WriteString(output);
};
}
}
You can’t perform that action at this time.