I have a dictionary, which I want to save to an excel or csv file with keys in one column and the entries in another. The keys are strings and the entries are float64s. I thought about converting my dictionary to a DataFrame but I am not sure if this type is supported in Julia or how to convert if it is, or even how to save a dataframe as csv. Can dictionaries be saved as csv files directly?
Thanks, that works. Is there a way to specify headers? I tried CSV.write("File.csv",VariableName,["Column1Name";"Column2Name]) but I got a Method error.
The example is only for Excel files and it’s using the XLSX package.
If you want to use CSV to write .csv files as in @TheLateKronos example, you could define your header as a comma delimited string, write that line to csv, and then write your test dictionary.
It seems you can specify custom column names when reading CSV’s, but I also just get the same error when I try to specify a vector of strings as column names. The best I can think of is to have the keyword argument append=true, which makes it so that column names are not written. Then you can add them yourself manually.
Alternatively find a way to write it to a dataframe with the column names you want, and save that