Can I write a DelimitedFile with a header?

alvrg
Wed, 07 Aug 2019 14:43:28 +0000
General Usage

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

# This is my matrix A
1 2
3 4

Thanks

3 posts - 2 participants