Re: Strange behaviour of format [message #44906] |
Fri, 22 July 2005 02:39 |
Norbert Hahn
Messages: 46 Registered: May 2003
|
Member |
|
|
David Fanning <davidf@dfanning.com> wrote:
> I couldn't get your example program to run, but I think you
> want the "colon format":
>
> IDL> print, string(indgen(4), format='(F7.2, :, ";" )')
> 0.00; 1.00; 2.00; 3.00
Well, that does the trick! Obviously I read over the colon
format description in the manual.
Thank you very much!
Norbert
|
|
|
Re: Strange behaviour of format [message #44914 is a reply to message #44906] |
Thu, 21 July 2005 11:37  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Norbert Hahn writes:
>
> I want to output CSV data using a ; as delimiter. The following example shows
> my problem:
>
> temp = '"'+'Some Text'+'"', indgen(4), format='(A,20(";",F7.2))'
> print, StrCompress(temp,/remove_all)
>
> results in
>
> "Some Text";0.00;1.00;2.00;3.00;
>
> The problem I have is the trailing semicolon. As a workaround I compute
> the number of elements in the integer array and insert that number in the
> format statement. Is there a better way to either omit the trailing ;
> or even to print CSV data?
I couldn't get your example program to run, but I think you
want the "colon format":
IDL> print, string(indgen(4), format='(F7.2, :, ";" )')
0.00; 1.00; 2.00; 3.00
For CVS data, just substitute a comma where the quoted
semi-colon is in the format statement.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|