CSV data manipulation: Difference between revisions
Content added Content deleted
Line 2,361: | Line 2,361: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang Julia>using DataFrames, CSV |
|||
Julia has rudimentary built-in support for csv input and output, which is certainly adequate for this task. More sophisticated support may be available with the <code>DataFrames</code> package. |
|||
<lang Julia> |
|||
ifn = "csv_data_manipulation_in.dat" |
ifn = "csv_data_manipulation_in.dat" |
||
ofn = "csv_data_manipulation_out.dat" |
ofn = "csv_data_manipulation_out.dat" |
||
df = CSV.read(ifn) |
|||
df.SUM = sum.(eachrow(df)) |
|||
(a, h) = readcsv(ifile, Int, header=true) |
|||
CSV.write(ofn, df) |
|||
close(ifile) |
|||
⚫ | |||
a = hcat(a, sum(a, 2)) |
|||
h = hcat(h, "SUM") |
|||
a = vcat(h, a) |
|||
ofile = open(ofn, "w") |
|||
writecsv(ofile, a) |
|||
close(ofile) |
|||
⚫ | |||
{{out}} |
|||
<pre> |
<pre> |
||
$ cat csv_data_manipulation_out.dat |
$ cat csv_data_manipulation_out.dat |