Question

I have a column called Name which has the following string:

F.M. Brown's Tropical Carnival Small Hookbill, 5-Pound
Kaytee Forti Diet Egg-Cite Food for Parakeets, 5-Pound Bag

I wan't to split the string using "," and then by "-" and have it in three columns called Product, Brand & Description. I couldn't find any string split functions that can be used for this. How can I split the string and add them to columns?

Was it helpful?

Solution

Field(%string%,%delimiter%,%occurrence%,[%number%])

DataStage Reference

You should make multiple Stage variables: Product, Brand and Description.

Example:

   Product SV: Field (DSLink.Name, “,”, 1, 1)
   Brand   SV: Field (DSLink.Name, “-”, 2, 1)
   Descrip SV: Field (DSLink.Name, “,”, 3, 1)

OTHER TIPS

I was asked this in an interview. The answers the web gives is based on space or delimiter but I was asked about one word split into many columns.

E.g.:abcdefghij as input and abcde as col1 and fghij as col2.

So my logic would be to use the beginning of the word till col1=left(len[str/2])) for first col and c0l2=left((len[str/2])+1) till the rest of the word, inserted as col2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top