# Formatted output in file based on DataFrames and CSV

**URL:** <https://discourse.julialang.org/t/formatted-output-in-file-based-on-dataframes-and-csv/17240>\
**Category:** New to Julia\
**Created:** [November 7, 2018, 6:50am UTC](https://discourse.julialang.org/t/formatted-output-in-file-based-on-dataframes-and-csv/17240 "2018-11-07T06:50:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ceysa75](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ceysa75/32/19121_2.png) [@ceysa75](https://discourse.julialang.org/u/ceysa75)\
**Post date:** [November 7, 2018, 6:50am UTC](https://discourse.julialang.org/t/formatted-output-in-file-based-on-dataframes-and-csv/17240/1 "2018-11-07T06:50:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ceysa75](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ceysa75/32/19121_2.png) [@ceysa75](https://discourse.julialang.org/u/ceysa75)\
**Post date:** [November 8, 2018, 8:33pm UTC](https://discourse.julialang.org/t/formatted-output-in-file-based-on-dataframes-and-csv/17240/2 "2018-11-08T20:33:35Z")

</div>

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:

```julia
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

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [November 8, 2018, 10:24pm UTC](https://discourse.julialang.org/t/formatted-output-in-file-based-on-dataframes-and-csv/17240/3 "2018-11-08T22:24:53Z")

</div>

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`.
