comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Saving array into column fomratted text file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Saving array into column fomratted text file [message #8671] Wed, 09 April 1997 00:00 Go to next message
mila is currently offline  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 Go to previous message
G�nter Kargl is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Searching for fast linear interpolation routine
Next Topic: IDL not a typewriter?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:17:13 PDT 2025

Total time taken to generate the page: 0.00511 seconds