CSV data manipulation: Difference between revisions
Content deleted Content added
second attempt to overcome network errors (modification of preamble; addition of suggestions) |
Added zkl |
||
Line 1,354:
3,7,111,15,19
4,8,12,116,20
</pre>
=={{header|zkl}}==
<lang zkl>csvFile:=File("test.csv");
header:=csvFile.readln().strip();
data:=csvFile.pump(List,fcn(line){line.strip().split(",").apply("toInt")});
newFile:=File("test2.csv","w");
newFile.writeln(header+",sum");
data.pump(newFile.writeln,fcn(ns){String(ns.concat(","),",",ns.sum())});
newFile.close();</lang>
{{out}}
<pre>
$ cat test2.csv
C1,C2,C3,C4,C5,sum
1,5,9,13,17,45
2,6,10,14,18,50
3,7,11,15,19,55
4,8,12,16,20,60
</pre>
|