Marouane1994
Marouane1994

Reputation: 534

how to save the outputs of a code in CSV files in julia

I know this is a beginnerquestion but i'm having problems in saving my data into a CSV file for example like in this code:

function mar(x,y)
for i in 1:10
s=x*i+y
end
end

how to save sand xand y i just would like to know the procedure that's all.

Upvotes: 1

Views: 804

Answers (1)

Nils Gudat
Nils Gudat

Reputation: 13800

You can use the CSV.jl library, which includes the CSV.write function. Example:

julia> using CSV                                       

julia> x = rand(10); y = rand(10); s = (1:10).*x .+ y;

julia> CSV.write("out.csv", (s = s, x = x, y = y)) 

Here I'm constructing a NamedTuple from s, x, and y, which satisfies the Tables.jl interface and therefore can be written out to file by CSV.jl like any other table.

Upvotes: 3

Related Questions