I am confused about the CSV way of writing files.
My problem is really simple:
I have two arrays and I want to save them in a .csv file, but I also want the following column names above my data: Voltage [V] and Current [A] which obviously are strings.
I tried an example with names tuples, but I donβt like that the names are propagated to the .csv as well:
pushfirst!(diode_volt, βdiode voltage [V]β) pushfirst!(diode_crt, βdiode current [A]β) CSV.write(βdiode.csvβ, (diode_volt = diode_volt, diode_crt = diode_crt))
What is the shortest way to solve this?
Nevermind, I read the docs more carefully and you can overwrite the header : CSV.write("diode.csv", (diode_volt = diode_volt, diode_crt = diode_crt); header = ["Voltage [V]", "Current [A]"])
By default, CSV.write uses the namedtuple keys as column names, which is admittedly a bit awkward in your situation due to the spaces in the column names, but nevertheless, it would work to do:
Thank you all for your solutions! In the end I used @quinnjβs method because I didnβt want to include DataFrames in the setup for such a simple table.