[julia-users] Re: how to save array to text file "correctly"?

2016-06-27 Thread Hoang-Ngan Nguyen
Thanks,
Ngan

On Friday, June 24, 2016 at 2:50:56 AM UTC-7, Pieterjan Robbe wrote:
>
> f = open("myfile.csv","w")
>
> for i in 1:length(data)
>
> write(f,@sprintf("%20.16f\n",data[i]))
>
> end
>
> close(f)
>
>
> shell> cat myfile.csv
>
>  -0.5000
>
>   0.
>
>  -0.21819900
>
>   0.15396700
>
>  -0.17899000
>
>   0.12671700
>
>  -0.02243270
>
>   0.01600870
>
> Op vrijdag 24 juni 2016 04:55:37 UTC+2 schreef Hoang-Ngan Nguyen:
>>
>> Hi,
>>
>> I have the following array
>> data = [
>>  -0.5 
>>  0.0 
>>  -2.18199e-5
>>  1.53967e-5
>>  -1.7899e-5 
>>  1.26717e-5
>>  -2.24327e-6
>>  1.60087e-6]
>>
>>
>> When I save it using either 
>>
>> writecsv("filename.csv",data)
>>
>> or
>>
>> writedlm("filename.csv",data,",")
>>
>>
>> I get this
>> -.5
>> 0
>> -21819881018654233e-21
>> 153966589305464e-19
>> -17898976869144106e-21
>> 12671715235247999e-21
>> -22432716786997375e-22
>> 16008706220269127e-22
>>
>> Is there anyway for me to, instead, get the following:
>> -.5
>> 0
>> -.21819881018654233
>> .153966589305464
>> -.17898976869144106
>> .12671715235247999
>> -.022432716786997375
>> .016008706220269127
>>
>> Thanks,
>> Ngan
>>
>>

[julia-users] Re: how to save array to text file "correctly"?

2016-06-24 Thread Pieterjan Robbe


f = open("myfile.csv","w")

for i in 1:length(data)

write(f,@sprintf("%20.16f\n",data[i]))

end

close(f)


shell> cat myfile.csv

 -0.5000

  0.

 -0.21819900

  0.15396700

 -0.17899000

  0.12671700

 -0.02243270

  0.01600870

Op vrijdag 24 juni 2016 04:55:37 UTC+2 schreef Hoang-Ngan Nguyen:
>
> Hi,
>
> I have the following array
> data = [
>  -0.5 
>  0.0 
>  -2.18199e-5
>  1.53967e-5
>  -1.7899e-5 
>  1.26717e-5
>  -2.24327e-6
>  1.60087e-6]
>
>
> When I save it using either 
>
> writecsv("filename.csv",data)
>
> or
>
> writedlm("filename.csv",data,",")
>
>
> I get this
> -.5
> 0
> -21819881018654233e-21
> 153966589305464e-19
> -17898976869144106e-21
> 12671715235247999e-21
> -22432716786997375e-22
> 16008706220269127e-22
>
> Is there anyway for me to, instead, get the following:
> -.5
> 0
> -.21819881018654233
> .153966589305464
> -.17898976869144106
> .12671715235247999
> -.022432716786997375
> .016008706220269127
>
> Thanks,
> Ngan
>
>