| Re: Writing in text file [message #72695 is a reply to message #72694] |
Mon, 27 September 2010 04:16  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On 9/27/10 5:05 AM, Dave Poreh wrote:
> Folks
> Hi;
> I read some data like this:
> -1.8750000000 78.8750000000 1.317
> -1.8750000000 78.6250000000 1.284
> -1.8750000000 78.3750000000 1.216
> -1.8750000000 78.1250000000 1.148
> -1.8750000000 77.8750000000 1.080
> ���������� ��
> And when I want to write it,
> openw,1,'C.dat'
> z=transpose(reform([data[0,*],data[1,*],data[2,*]],n_element s(data[2,*]),
> 3))
> printf,1,z
> close,1
> it gives me something like this:
> -1.87500 0.897000 71.6250
> 78.8750 9.87500 0.645000
> 1.31700 70.3750 21.8750
> -1.87500 1.01300 71.3750
> 78.6250 9.87500 0.538000
> 1.28400 70.1250 21.8750
> ���.
> Will you please help me out whit this?
> Cheers
> Dave
Hi Dave,
You haven't said what you expected to see, but clearly the transpose is
making this come out 'funny'. Here's what I see when I simply readf
from a file ("data-int.txt") and then printf the data to a file
("data-out.txt").
Cheers,
Ben
{ x86_64 darwin unix Mac OS X 7.1 Apr 21 2009 64 64}
;data-in.txt looks like the following
;-1.8750000000 78.8750000000 1.317
;-1.8750000000 78.6250000000 1.284
;-1.8750000000 78.3750000000 1.216
;-1.8750000000 78.1250000000 1.148
;-1.8750000000 77.8750000000 1.080
infile = "data-in.txt"
n = FILE_LINES(infile)
s = FLTARR(3, n)
OPENR, U, infile, /GET_LUN
READF, U, s
FREE_LUN, u
outfile = "data-out.txt"
OPENW,U, outfile,/GET_LUN
PRINTF, U, s
FREE_LUN, U
; data-out.txt looks like the following
; -1.87500 78.8750 1.31700
; -1.87500 78.6250 1.28400
; -1.87500 78.3750 1.21600
; -1.87500 78.1250 1.14800
; -1.87500 77.8750 1.08000
|
|
|
|