Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,32 @@
|
|||
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);
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue