# Writing array to file with format

**URL:** <https://discourse.julialang.org/t/writing-array-to-file-with-format/96175>\
**Category:** New to Julia\
**Tags:** io, formatting\
**Created:** [March 16, 2023, 11:08am UTC](https://discourse.julialang.org/t/writing-array-to-file-with-format/96175 "2023-03-16T11:08:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 16, 2023, 11:33am UTC](https://discourse.julialang.org/t/writing-array-to-file-with-format/96175/2 "2023-03-16T11:33:57Z")

</div>

> [@Andres\_Legarra](#):
>
> I am aware of `Printf` and of @printf and of @sprintf and of this thread [How to repeat the format in @printf?](https://discourse.julialang.org/t/how-to-repeat-the-format-in-printf/66695) but I have not been able to find a neat solution or a clear example that would not involve joins, broadcasting functions, etc. Am I missing something?

What’s wrong with a loop?

```julia
for i = axes(A, 1)
    for j = axes(A, 2)
        @printf(io, "%9.5f", A[i,j])
    end
    println(io)
end

```

> [@Andres\_Legarra](#):
>
> (contrary to python or fortran) `write` does not directly accept formats (or I couldn’t find how).

`write` in Julia is for raw binary output, not for text representations of numeric data.

---

_[View the full topic](https://discourse.julialang.org/t/writing-array-to-file-with-format/96175)._
