DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
Author Message
edison
Participant



Joined: 17 Sep 2007
Posts: 19

Points: 118

Post Posted: Mon May 14, 2012 11:51 am Reply with quote    Back to top    

DataStage® Release: 8x
Job Type: Server
OS: Windows
Additional info: Source file Parsing
Hi,

Src file Sequential, Pipe Delimeter, DataTYpe Varchar(10)

0001,0002|Truck,Rail Car
0001|Truck
0002,0001|Rail Car,Truck

Output needed

0001|Truck
0002|Rail Car
0001|Truck
0002|Rail Car
0001|Truck

_________________
Nokia8800
mobashshar
Participant



Joined: 20 Apr 2005
Posts: 80
Location: U.S.
Points: 412

Post Posted: Mon May 14, 2012 1:45 pm Reply with quote    Back to top    

What have you tried so far?
Rate this response:  
Not yet rated
edison
Participant



Joined: 17 Sep 2007
Posts: 19

Points: 118

Post Posted: Mon May 14, 2012 1:49 pm Reply with quote    Back to top    

Convert(Convert(‘,’,’’, col1), ‘,’, ‘’) = ‘,’ then substring the value using delimiter

Not getting upto point.

_________________
Nokia8800
Rate this response:  
Not yet rated
venkateshrupineni
Participant



Joined: 02 May 2012
Posts: 15

Points: 99

Post Posted: Fri Jun 29, 2012 12:08 am Reply with quote    Back to top    

in stage variables
write as like simle way

sv1=field(col1,'|',1) it will give filed1 of 0001,0002
sv2=field(col1,'|',2) it will give field2 of Truck,Rail Carsv3
then
sv3 = field(sv1,',',1) it will give 0001
sv4 = field(sv1,',',2) it will give 0002
sv5=field(sv2,',',1) it will give Truck
sv6 = field(sv2,',',2) it will give Rail Carsv3

then after you can concatenate as per your requirement

------------------------
Venky
Rate this response:  
Kryt0n
Participant



Joined: 22 Jun 2005
Posts: 584

Points: 3356

Post Posted: Fri Jun 29, 2012 12:49 am Reply with quote    Back to top    

Does it have to be done in a Server job? Parallel looping would be far more appropriate.

Not sure how much of this would work as haven't tried myself and more thought process than certainty.

As you haven't named any of it, having a pipe delimiter, the first column I will call seqno. So how many comma-separated seqno values can you get in one row?

Split your incoming data on the pipe
Define a stage variable (svSeqNo) as a comma separated sequential numerics to represent how many seqnos you can get in one row (i.e. 1,2,3,4...)
Add a new output column called seqnocount (or whatever) as
- Field(svSeqNo, ',', 1, DCount(seqno,','))
for your first row, this should give the result "1,2"
Use a row splitter with this new column (seqnocount) as your split column and needs to create a new row for each (don't ask me how, haven't tried, will be good practice for you)
This should give you an output of
1<delim>0001,0002<delim>Truck,Rail Car
2<delim>0001,0002<delim>Truck,Rail Car
etc
After row splitter, use a transform stage to output the delimited field to match your seqnocount
i.e. Field(seqno,',',seqnocount)
Rate this response:  
Not yet rated
battaliou
Participant



Joined: 24 Feb 2003
Posts: 135
Location: London
Points: 789

Post Posted: Fri Jun 29, 2012 2:29 am Reply with quote    Back to top    

If you use venkateshrupineni solution then you can have two output's from your transformer into a funnel with a contraint on the 2nd output based on whether sv4<>''

_________________
CENTURION: What's this, then? 'Romanes Eunt Domus'? 'People called Romanes they go the house'?

BRIAN: It-- it says, 'Romans, go home'.

Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 49935
Location: Canberra, Australia
Points: 271389

Post Posted: Fri Jun 29, 2012 5:45 am Reply with quote    Back to top    

... except that there's no Funnel stage in server jobs. Though a hashed file can be employed to the same end, though needing a generated key.

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong
Delivering Outcomes Together
Rate this response:  
Not yet rated
Kryt0n
Participant



Joined: 22 Jun 2005
Posts: 584

Points: 3356

Post Posted: Sun Jul 01, 2012 4:39 pm Reply with quote    Back to top    

battaliou wrote:
If you use venkateshrupineni solution then you can have two output's from your transformer into a funnel with a contraint on the 2nd output based on whether sv4<>''


Or just separate the two by a cr/crlf if outputting to a sequential file but what if there are three or more comma separated values?
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours