How to specify the format in writedlm?


#1

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


#2

See


#3

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