The following only applies if you have the latest version of Tables.jl (which is 0.1.14), I’m not sure it will work in earlier versions.
NamedTuple is an object of type
(a=1, b="something"): like a
Tuple except it has names. An
NamedTuples (for example
v = [(a=i, b=i+1) for i in 1:3]) can be considered a table and therefore you can do
CSV.write(filename, v). I thought
am was a vector of named tuples. If it isn’t, instead of allocating a
DataFrame (in case your data is really big and you are afraid this could slow things down) you can simply generate a
NamedTuple iterator and write it to CSV.
itr = ((name1=a.name1, name2=a.name2, name3=a.name3) for a in am)
This way you avoid allocating the
DataFrame and the data is streamed directly from your vector to the CSV. Note that
itr is probably a better way to convert to
DataFrame. For example you could just do
DataFrame(itr) and get the
DataFrame (avoiding the temporary vectors
[a.name1, a.name2, a.name3]).