|
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   |
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 #76863 is a reply to message #76862] |
Tue, 12 July 2011 04:06   |
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   |
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  |
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 :-)
|
|
|