How to resolve the algorithm CSV data manipulation step by step in the Maple programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm CSV data manipulation step by step in the Maple programming language
Table of Contents
Problem Statement
CSV spreadsheet files are suitable for storing tabular data in a relatively portable way.
The CSV format is flexible but somewhat ill-defined.
For present purposes, authors may assume that the data fields contain no commas, backslashes, or quotation marks.
Read a CSV file, change some values and save the changes back to a file. For this task we will use the following CSV file: Suggestions
Let's start with the solution:
Step by Step solution about How to resolve the algorithm CSV data manipulation step by step in the Maple programming language
Source code in the maple programming language
M := ImportMatrix("data.csv",source=csv);
M(..,6) := < "Total", seq( add(M[i,j], j=1..5), i=2..5 ) >;
ExportMatrix("data_out.csv",M,target=csv);
> M := ImportMatrix("data.csv",source=csv);
["C1" "C2" "C3" "C4" "C5"]
[ ]
[ 1 5 9 13 17 ]
[ ]
M := [ 2 6 10 14 18 ]
[ ]
[ 3 7 11 15 19 ]
[ ]
[ 4 8 12 16 20 ]
> M(..,6) := < "Total", seq( add(M[i,j], j=1..5), i=2..5 ) >;
["C1" "C2" "C3" "C4" "C5" "Total"]
[ ]
[ 1 5 9 13 17 45 ]
[ ]
M := [ 2 6 10 14 18 50 ]
[ ]
[ 3 7 11 15 19 55 ]
[ ]
[ 4 8 12 16 20 60 ]
> ExportMatrix("data_out.csv",M,target=csv);
96
You may also check:How to resolve the algorithm Deepcopy step by step in the Sidef programming language
You may also check:How to resolve the algorithm Factorial step by step in the Octave programming language
You may also check:How to resolve the algorithm Rosetta Code/Count examples step by step in the OCaml programming language
You may also check:How to resolve the algorithm Mutex step by step in the Oforth programming language
You may also check:How to resolve the algorithm Substring/Top and tail step by step in the Plain English programming language