Formatted output in file based on DataFrames and CSV


#1

Dear all,

I wonder if it is possible to specify the fomat if writing data in a file based on DataFrames and CSV. E.g. '%.4f' prints pi as '3.1416'.
THX a lot


#2

Ok, just for further explaining my question. I can reach my goal, if it is intendend to write print formatted values on screen as follows:

for i = 1:5
x = (0.33/i)^2
    @printf("%13.8f\n",x)
end

And now I am looking for a way, to write the formatted data into a file. Using CSV.write and DataFrames doesn’t seem to work for this purpose. Is there really no way ?
Thanks in advance


#3

Assuming your data is not very large you can create a new DataFrame which will contain the columns appropriately converted to strings and then save such a DataFrame.