CSV data manipulation: Difference between revisions
Content added Content deleted
(Added Easylang) |
No edit summary |
||
Line 3,116: | Line 3,116: | ||
4,8,12,16,20,60 |
4,8,12,16,20,60 |
||
"</syntaxhighlight> |
"</syntaxhighlight> |
||
=={{header|Logo}}== |
|||
{{works with|UCBLogo|6.2.4}} |
|||
UCBLogo has no built-in support for generic CSV files. |
|||
<syntaxhighlight lang="logo">to csv.data.manipulation :in :out |
|||
local [header line list sum] |
|||
openread :in |
|||
setread :in |
|||
openwrite :out |
|||
setwrite :out |
|||
make "header readword |
|||
print word :header ",SUM |
|||
while [not eofp] [ |
|||
make "line readword |
|||
make "list parse map [ifelse equalp ? ", ["\ ] [?]] :line |
|||
make "sum apply "sum :list |
|||
print (word :line "\, :sum) |
|||
] |
|||
close :in |
|||
setread [] |
|||
close :out |
|||
setwrite [] |
|||
end</syntaxhighlight> |
|||
<syntaxhighlight lang="logo">csv.data.manipulation "data.csv "output.csv</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Contents of output.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> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |