Re: Formatted printf output [message #76623] |
Tue, 21 June 2011 07:11  |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Tue, 21 Jun 2011 06:30:11 -0700 (PDT), Axel M <axelus@gmail.com>
wrote:
> Hi,
> I am trying to print a list of numerical values into a .txt file to be
> later imported by Excel. For this purpose, I want to change IDL's
> output when printing from 2.35 to 2,35 (comma).
> I was looking in the format codes in printf but was not successful...
> Somebody has a clue how to do that?
Other than converting to a string and parsing with STRSPLIT/STRJOIN or
STRPOS/STRPUT, I wouldn't know.
|
|
|
Re: Formatted printf output [message #76704 is a reply to message #76623] |
Wed, 22 June 2011 03:12  |
Axel Martínez
Messages: 22 Registered: June 2010
|
Junior Member |
|
|
On Jun 21, 4:11 pm, Wox <s...@nomail.com> wrote:
> On Tue, 21 Jun 2011 06:30:11 -0700 (PDT), Axel M <axe...@gmail.com>
> wrote:
>
>> Hi,
>> I am trying to print a list of numerical values into a .txt file to be
>> later imported by Excel. For this purpose, I want to change IDL's
>> output when printing from 2.35 to 2,35 (comma).
>> I was looking in the format codes in printf but was not successful...
>> Somebody has a clue how to do that?
>
> Other than converting to a string and parsing with STRSPLIT/STRJOIN or
> STRPOS/STRPUT, I wouldn't know.
Ok, thanks.
It is not optimal in my situation, because STRPUT and STRPOS accept
string arrays, but STRPUT accepts only a scalar value for the
position, so that I would need to create a FOR loop iterating over
each single value...
Is there some other solution using string formatting which would avoid
this? I copy my simple code below.
;Save a 1D or 2D array as text file with : separated values which can
be imported by Excel
PRO XLS_save, fn, data
OPENW, unit, fn, /GET_LUN
FOR i=0, (SIZE(data, /DIMENSIONS))[0]-1 DO BEGIN
printf, unit, STRJOIN(STRING(REFORM(data[i,*])), ':')
ENDFOR
CLOSE, unit & FREE_LUN, unit
END
|
|
|