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

Home » Public Forums » archive » Re: Adding values to a string
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Adding values to a string [message #49038 is a reply to message #49037] Thu, 08 June 2006 13:34 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
One way:

text='M5A,060530,181005,4302003340bf,1149012,,,,,15.70765,89 3.439514,7.73610973'

IDL> parts=STRSPLIT(text, ',', /EXTRACT, /PRESERVE_NULL)
IDL> parts[WHERE(parts eq '')] = '0'
IDL> newText = STRJOIN(parts, ',', /SINGLE)
IDL> print, newText
M5A,060530,181005,4302003340bf,1149012,0,0,0,0,15.70765,893. 439514,7.73610973

-Rick

rafaloos@gmail.com wrote:
> Hi ...
> I have a string like this:
>
> 'M5A,060530,181005,4302003340bf,1149012,,,,,15.70765,893.439 514,7.73610973'
>
> As you can see this string has some extra commas. Values were supposed
> to be in between these commas, but they are not.
>
> I want to ADD some zeros in the above string so that in the end my
> string will be like this:
>
> 'M5A,060530,181005,4302003340bf,1149012,0,0,0,0,15.70765,893 .4395141,7.73610973'
>
> Is there a easy way to do that ?
>
> Thank you
>
[Message index]
 
Read Message
Read Message
Previous Topic: Adding values to a string
Next Topic: contouring data over a map

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

Current Time: Sat Oct 11 04:07:26 PDT 2025

Total time taken to generate the page: 1.19958 seconds