Saving array into column fomratted text file [message #8671] |
Wed, 09 April 1997 00:00  |
mila
Messages: 5 Registered: July 1996
|
Junior Member |
|
|
I have IDL arrays, that I would like to write out to a text file
so that it retains the dimensionality in the form of rows and columns.
For example, if I have an array test(360,180), I would like to write it out
to a text file with 360 columns and 180 rows.
Anyone have any better suggestions than the solution I am using below:
openw,1,'output_file'
printf,1,test,format=`(360f6.2)'
close,1
I have found programs in IDL on the net that read column formatted files,
but havent found any that write out to columns.
I would appreciate any tips.
Thanks,
Mila Mitra
|
|
|
Re: Saving array into column fomratted text file [message #8727 is a reply to message #8671] |
Wed, 16 April 1997 00:00  |
G�nter Kargl
Messages: 3 Registered: October 1996
|
Junior Member |
|
|
Mila Mitra wrote:
I have IDL arrays, that I would like to write out to a text file
so that it retains the dimensionality in the form of rows and
columns.
For example, if I have an array test(360,180), I would like to write
it out
to a text file with 360 columns and 180 rows.
Anyone have any better suggestions than the solution I am using
below:
openw,1,'output_file'
printf,1,test,format=`(360f6.2)'
close,1
I have found programs in IDL on the net that read column formatted
files,
but havent found any that write out to columns.
I would appreciate any tips.
Thanks,
Mila Mitra
Hi Mila,
the way you suggest is right. for more flexibility try
columns=n_elements(data(*,0))
format_string= '(' + strtrim(string(columns),2) + 'f9.4)'
openw,/get_lun,file_unit,out_file
printf,file_unit,data,format=format_string
free_lun,file_unit
There are possibly more ways to do it, but this is straight forward and
no effort.
Have a nice time
G�nter
--
Kargl G�nter mailto:kargl@linax1.mpae.gwdg.de
Max-Planck Inst, f. Aeronomie Phone: ++49 5556 979 234
Max-Planck Str. 2 Fax:: ++49 5556 979 240
D- 37191 Katlenburg-Lindau
Germany
Don't Panic
|
|
|