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

Home » Public Forums » archive » Formatted printf output
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
Formatted printf output [message #76624] Tue, 21 June 2011 06:30 Go to next message
Axel Martínez is currently offline  Axel Martínez
Messages: 22
Registered: June 2010
Junior Member
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?
Re: Formatted printf output [message #76695 is a reply to message #76624] Wed, 22 June 2011 09:13 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Wed, 22 Jun 2011, Gray wrote:

> On Jun 22, 10:15 am, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
>> In article
>> < 49155f70-81fc-4da6-8247-ea81b30d0...@l6g2000vbn.googlegroups .com >,
>>  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?
>>
>> You could write the file with periods and then use a text editor
>> to convert all of the periods to commas.
>>
>> Ken Bowman
>
> Use REPSTR() from the NASA IDL astronomy library.
>

You can write your own character replacing routine:

a='1.234 5.678'
b=byte(a)
p=where(b eq (byte('.'))[0], count)
if count gt 0 then b[p]=(byte(','))[0]
c=string(b)
print, c

regards,
Lajos
Re: Formatted printf output [message #76698 is a reply to message #76624] Wed, 22 June 2011 08:32 Go to previous messageGo to next message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Jun 22, 10:15 am, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> In article
> < 49155f70-81fc-4da6-8247-ea81b30d0...@l6g2000vbn.googlegroups .com >,
>  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?
>
> You could write the file with periods and then use a text editor
> to convert all of the periods to commas.
>
> Ken Bowman

Use REPSTR() from the NASA IDL astronomy library.
Re: Formatted printf output [message #76699 is a reply to message #76624] Wed, 22 June 2011 07:15 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<49155f70-81fc-4da6-8247-ea81b30d0f38@l6g2000vbn.googlegroups.com>,
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?

You could write the file with periods and then use a text editor
to convert all of the periods to commas.

Ken Bowman
Re: Formatted printf output [message #76743 is a reply to message #76695] Mon, 27 June 2011 01:02 Go to previous message
Axel Martínez is currently offline  Axel Martínez
Messages: 22
Registered: June 2010
Junior Member
On Jun 22, 6:13 pm, FÖLDY Lajos <fo...@rmki.kfki.hu> wrote:
> On Wed, 22 Jun 2011, Gray wrote:
>> On Jun 22, 10:15 am, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
>>> In article
>>> < 49155f70-81fc-4da6-8247-ea81b30d0...@l6g2000vbn.googlegroups .com >,
>>>  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?
>
>>> You could write the file with periods and then use a text editor
>>> to convert all of the periods to commas.
>
>>> Ken Bowman
>
>> Use REPSTR() from the NASA IDL astronomy library.
>
> You can write your own character replacing routine:
>
> a='1.234 5.678'
> b=byte(a)
> p=where(b eq (byte('.'))[0], count)
> if count gt 0 then b[p]=(byte(','))[0]
> c=string(b)
> print, c
>
> regards,
> Lajos

Thanks for the useful suggestions. I just implemented the last one.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Latitude longitude and Image Navigation
Next Topic: Very strange problem in IDL histogram, A bug???

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

Current Time: Wed Oct 08 11:34:50 PDT 2025

Total time taken to generate the page: 0.00542 seconds