New line character

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
qutesanju
Participant
Posts: 373
Joined: Tue Aug 26, 2008 4:52 am

New line character

Post by qutesanju »

I have a job that prepares a sequencial file as

Total_Data_Count File_Count Filter_Count
100 10 20

is there a way that I can modify the sequencial file to as
Total_Data_Count,100
File_Count,10
Filter_Count,20
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Looks like a straightforward pivot to me, after you've generated the column heading "values".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post by bhasds »

Hi qutesanju,

You may try the below-

1.In stage variable of the transformer-

Code: Select all

SV1:",":col1   SV1 (initilize with null)
SV2:",":col2  SV2(initilize with null)
SV3:",":col3  SV3(initilize with null)
2. In derivation-

Code: Select all

SV1:"|":SV2:"|":SV3  outputcol
Execute the transformer stage in sequential mode.
3.In the Filter option of the sequential file stage-

Code: Select all

tail -1 | tr -s '|' '\n'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I agree, it's just a pivot. Hard-code three new columns with the 'column names' and then pivot them with their matching data column. Write out the file without enabling the column headings option.
-craig

"You can never have too many knives" -- Logan Nine Fingers
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post by bhasds »

Hi cutesanju

As Craig said if you drop the headers then a little change in the previous code-

In derivation, instead of this
SV1:"|":SV2:"|":SV3 outputcol
Use the below-

Code: Select all

Total_Data_Count:SV1:"|":File_Count:SV2:"|":Filter_Count:SV3  outputcol
The other things will remain same.
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Post by BI-RMA »

Hi bhasds,

You are misinterpreting Craigs post: no transformer necessary, no stage-variables. Just a pivot-stage.
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post by bhasds »

Hi BI-RMA,

I am sorry for the misinterpretation.I had concentrated on changing my existing code in the previous post.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Of course, there are other games you can play. You could build and write out a single record much as posted but rather than the pipes separate the three segments with a line feed. You'll write out one record but anything reading it will read three:

Code: Select all

svLF = CHAR(10)

Output = 'Total_Data_Count,' : Col1 : svLF : 'File_Count,' : Col2 : svLF :  'Filter_Count,' : Col3
Again, make sure to not enable column headers while writing.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply