# How to specify the format in writedlm?

**URL:** https://discourse.julialang.org/t/how-to-specify-the-format-in-writedlm/4058
**Category:** General Usage
**Created:** [June 2, 2017, 2:50pm UTC](https://discourse.julialang.org/t/how-to-specify-the-format-in-writedlm/4058 "2017-06-02T14:50:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jmo](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jmo](https://discourse.julialang.org/u/jmo)
#### Post date: [June 2, 2017, 2:50pm UTC](https://discourse.julialang.org/t/how-to-specify-the-format-in-writedlm/4058/1 "2017-06-02T14:50:05Z")

</div>

Hi,  
I’m trying to write an array to a text file using writedlm. The array contains small floating point numbers but Julia saves it in a very odd format.

Can I specify the format to e.g. “%g”?

My problem can be illustrated by:

julia\> VERSION  
v"0.5.2"

julia\> a=rand(10)/1e8  
10-element Array{Float64,1}:  
7.95137e-9  
3.26463e-9  
8.57709e-9  
5.623e-9  
1.18668e-9  
4.79027e-9  
2.98404e-9  
3.67931e-9  
7.92933e-9  
9.32614e-9

julia\> writedlm(“test.txt”,a)

shell\> cat test.txt  
7951367936085416e-24  
32646314198289182e-25  
857708986868636e-23  
5622998959757808e-24  
11866818183793715e-25  
4790274376055203e-24  
29840432453930554e-25  
36793133432091363e-25  
7929332595738798e-24  
9326137418330871e-24

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [June 2, 2017, 3:31pm UTC](https://discourse.julialang.org/t/how-to-specify-the-format-in-writedlm/4058/2 "2017-06-02T15:31:55Z")

</div>

See

> [@More control over writedlm formatting](https://discourse.julialang.org/t/more-control-over-writedlm-formatting/2840):
>
> Hi, I’ve recently discovered that writedlm() tends to output floating-point numbers using a very strange format pattern which removes the fractional part by decreasing exponent. Not only it is terribly confusing, the data is no longer easy to read and understand by a human. An example: 6.0444e-5 -\> 60444e-9 2.15234e-5 -\> 215234e-10 3.3253e-5 -\> 33253e-9 It is not a bug - print\_shortest has done it job by reducing the output by exactly one character - a decimal mark. But it is not human reada…

---

<div class="post-metadata">

### Author: ![jmo](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@jmo](https://discourse.julialang.org/u/jmo)
#### Post date: [June 2, 2017, 3:55pm UTC](https://discourse.julialang.org/t/how-to-specify-the-format-in-writedlm/4058/3 "2017-06-02T15:55:01Z")

</div>

Ok, thanks!  
It seems the recommendation is to abandon writedlm and use the CSV package instead.
