Getting word with comma separated value



IBM's Command List programming language & Restructured Extended Executor

Getting word with comma separated value

Postby samb01 » Wed Feb 20, 2019 6:03 pm

Hello,
i have those records in my dataset :


AAA,BBB,CCC,DDD
EEEEEEEEEE,FF,GGGGGGGGGG
 


I'd like to get the word separated with comma

For example, in the first line, i'd like to get :

AAA
BBB
CCC
and in the secand line :
EEEEEEEEEE
FF
GGGGGGGGGG

I can't use WORD function because, it is not space separated value...

Thank's.
samb01
 
Posts: 427
Joined: Mon Nov 16, 2009 7:24 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Getting word with comma separated value

Postby willy jensen » Wed Feb 20, 2019 6:41 pm

Change the commas to blanks: line=translate(line,' ',',')
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Getting word with comma separated value

Postby enrico-sorichetti » Wed Feb 20, 2019 7:20 pm


s = "aaa,     bbb,ccc     "
do while ( s \= "" )
    parse var s w "," s
    say strip(w)
end
 


posted gazillions of times in many forums
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Getting word with comma separated value

Postby samb01 » Thu Feb 21, 2019 3:37 pm

Thank you enrico, t didn't think about the command PARSE wich is very usefull :D
samb01
 
Posts: 427
Joined: Mon Nov 16, 2009 7:24 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Getting word with comma separated value

Postby willy jensen » Thu Feb 21, 2019 7:17 pm

PARSE is a very useful command. In this particular case, assuming that you have only 3 words, you can combine the TRANSLATE and PARSE thus:
parse value translate(string,' ',',') with p1 p2 p3 .  
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times


Return to CLIST & REXX