Writing only a header with CSV.jl

I am writing a csv file appending arrays with CSV.write(...;append=true).

How can I write the header before I start to iterate? I have tried to create an empty table without success.

Does this work? You can also add headers using the kwargs.

using CSV
open("test.csv", "w") do f
    CSV.write(f,[], writeheader=true, header=["A", "B","C","D"])
    # Append more info to f
end
2 Likes

I was missing the []. Many thanks!