Page 1 of 1

Getting word with comma separated value

PostPosted: Wed Feb 20, 2019 6:03 pm
by samb01
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.

Re: Getting word with comma separated value

PostPosted: Wed Feb 20, 2019 6:41 pm
by willy jensen
Change the commas to blanks: line=translate(line,' ',',')

Re: Getting word with comma separated value

PostPosted: Wed Feb 20, 2019 7:20 pm
by enrico-sorichetti

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


posted gazillions of times in many forums

Re: Getting word with comma separated value

PostPosted: Thu Feb 21, 2019 3:37 pm
by samb01
Thank you enrico, t didn't think about the command PARSE wich is very usefull :D

Re: Getting word with comma separated value

PostPosted: Thu Feb 21, 2019 7:17 pm
by willy jensen
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 .