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

Home » Public Forums » archive » Re: Writing 2D array to Text File
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Writing 2D array to Text File [message #67762 is a reply to message #67759] Fri, 21 August 2009 12:09 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Vikram wrote:
> Hello IDL Gurus,
>
> I would like to write a 2D array that I have [120,120], to a text
> file. When I write the array out now, everything appears in 1 column
> with 14400 rows:
>
> for i = 0,119 do begin
> for j = 0,119 do begin
> PRINTF,lun,array[i,j]
> endfor
> endfor
>
> Is there anyway that I can format my PRINTF to print 120 columns and
> 120 rows, for viewing in Excel. Any ideas?
>
> Thanks,
> Vikram

Vikram,

you can play with the format keyword...
something like this:

print, a, format='(120(A,","))' ==> will put a comma after each value

or

print, a, format='(120A)' ==>will write by 120 cols.

So, in your case, just remove the loops...

PRINTF,lun,array, format = '(120A)'

You can even change the 120 by n_elements(array[*,0]) etc

Jean
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Bus Error on Mac when TVRD() is called in IDL 6.4
Next Topic: Loop Multiple Files and Rename

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

Current Time: Fri Oct 10 19:40:55 PDT 2025

Total time taken to generate the page: 1.56536 seconds