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

Home » Public Forums » archive » Re: Writing a lot of data to ASCII file without a loop?
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
Re: Writing a lot of data to ASCII file without a loop? [message #76860] Tue, 12 July 2011 04:41 Go to next message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
On 12/07/11 13:06, Rob wrote:
> That doesn't seem to quite work as it prints one below the other
> rather than in two columns.

Yup, little copy-and-paste error.

chl
Re: Writing a lot of data to ASCII file without a loop? [message #76861 is a reply to message #76860] Tue, 12 July 2011 04:34 Go to previous messageGo to next message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On 7/12/11 7:06 AM, Rob wrote:
> On Jul 12, 11:45 am, Carsten Lechte<c...@toppoint.de> wrote:
>> On 12/07/11 12:11, Rob wrote:
>>
>>> I need to write a large array of values to an ASCII file in two long
>>> columns and wondered if there was a quick way of doing it.
>>
>> Write them as a single array:
>>
>> IDL> s1 = [1,2,3,4]
>> IDL> s2 = [5,6,4,1]
>> IDL> writeit = TRANSPOSE([[s1],[s2]])
>> IDL> print, writeit, format = '(G15.9)'
>> 1.00000000 5.00000000
>> 2.00000000 6.00000000
>> 3.00000000 4.00000000
>> 4.00000000 1.00000000
>>
>> That gets rid of the loop, but still does a lot of binary-to-ascii
>> conversions, so do not expect miracles.
>>
>> chl
>
> That doesn't seem to quite work as it prints one below the other
> rather than in two columns.
>
> e.g. in your example it'd be
>
> 1
> 5
> 2
> 6
> 3
> 4
> 4
> 1
Hi,

I suspect he meant to write...

print, writeit, format = '(2G15.9)'

Note the 2, meaning print output in pairs.

Cheers,
Ben
Re: Writing a lot of data to ASCII file without a loop? [message #76862 is a reply to message #76861] Tue, 12 July 2011 04:09 Go to previous messageGo to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Jul 12, 12:06 pm, Rob <rj...@le.ac.uk> wrote:
>
> That doesn't seem to quite work as it prints one below the other
> rather than in two columns.

format = '(2G15.9)' works
Re: Writing a lot of data to ASCII file without a loop? [message #76863 is a reply to message #76862] Tue, 12 July 2011 04:06 Go to previous messageGo to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Jul 12, 11:45 am, Carsten Lechte <c...@toppoint.de> wrote:
> On 12/07/11 12:11, Rob wrote:
>
>> I need to write a large array of values to an ASCII file in two long
>> columns and wondered if there was a quick way of doing it.
>
> Write them as a single array:
>
> IDL> s1 = [1,2,3,4]
> IDL> s2 = [5,6,4,1]
> IDL> writeit = TRANSPOSE([[s1],[s2]])
> IDL> print, writeit, format = '(G15.9)'
>        1.00000000      5.00000000
>        2.00000000      6.00000000
>        3.00000000      4.00000000
>        4.00000000      1.00000000
>
> That gets rid of the loop, but still does a lot of binary-to-ascii
> conversions, so do not expect miracles.
>
> chl

That doesn't seem to quite work as it prints one below the other
rather than in two columns.

e.g. in your example it'd be

1
5
2
6
3
4
4
1
Re: Writing a lot of data to ASCII file without a loop? [message #76864 is a reply to message #76863] Tue, 12 July 2011 03:45 Go to previous messageGo to next message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
On 12/07/11 12:11, Rob wrote:
> I need to write a large array of values to an ASCII file in two long
> columns and wondered if there was a quick way of doing it.

Write them as a single array:

IDL> s1 = [1,2,3,4]
IDL> s2 = [5,6,4,1]
IDL> writeit = TRANSPOSE([[s1],[s2]])
IDL> print, writeit, format = '(G15.9)'
1.00000000 5.00000000
2.00000000 6.00000000
3.00000000 4.00000000
4.00000000 1.00000000

That gets rid of the loop, but still does a lot of binary-to-ascii
conversions, so do not expect miracles.


chl
Re: Writing a lot of data to ASCII file without a loop? [message #76958 is a reply to message #76860] Tue, 12 July 2011 05:55 Go to previous message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Jul 12, 12:41 pm, Carsten Lechte <c...@toppoint.de> wrote:
> On 12/07/11 13:06, Rob wrote:
>
>> That doesn't seem to quite work as it prints one below the other
>> rather than in two columns.
>
> Yup, little copy-and-paste error.
>
> chl


Thanks eveyrone. This has significantly sped up my code :-)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Writing a lot of data to ASCII file without a loop?
Next Topic: Re: Ready to quit after 25 years...

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

Current Time: Wed Oct 08 19:43:18 PDT 2025

Total time taken to generate the page: 0.00511 seconds