Hi, I would like to save a matrix in txt format (I know there are better alternatives, but this is a two-liner). I can do that with

using DelimitedFiles A = [[1 2]; [3 4]] writedlm("./data.txt", A)

Can I also write a header in the file using writedlm? For example, the file would read

writedlm

# This is my matrix A 1 2 3 4

Thanks

Sure:

julia> using DelimitedFiles julia> a = [[1 2]; [3 4]] 2×2 Array{Int64,2}: 1 2 3 4 julia> open("data.txt"; write=true) do f write(f, "# This is my matrix A\n") writedlm(f, a) end shell> cat data.txt # This is my matrix A 1 2 3 4

Great! Just what I wanted, thanks!