Reading from fixed length file

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
Gen1715
Participant
Posts: 25
Joined: Mon Nov 05, 2012 5:42 am
Location: India

Reading from fixed length file

Post by Gen1715 »

I have a requirement of reading from fixed length file(Length 30) -
spaces are coming from source for less length and NULL field.

sample file -
$ cat poctest.txt
seq# Name marks per grd
000001Ram 000098098.00A+
000002Sham 000078078.00B+
000003Sumit 000068068.00B
000000 000000000.00

I read it through sequential file -
seq# - varchar(6)
Name - Varchar(10)
marks - varchar(6)
per - varchar(6)
grd - varchar(2)

by specifying delimiter as 'none' and final delimiter as 'end' and read it through 5 different columns and I am able to read file in 5 different columns. Now, I want to have same file format with a delimiter '|' to be propogated to another sequential file.
My Design -

Seq File Stage --> Copy Stage --> Seq File Stage

this design is giving me same structure of file as of source (i.e, without delimiter).

Can anyone please tell how this can be done.

P.S. - Is there anything specific need to be defined in DS to make it understand that source file is fixed length.
Gaurav Martha
abhijain
Participant
Posts: 88
Joined: Wed Jun 13, 2007 1:10 pm
Location: India

Post by abhijain »

specify the delimiter as "|" for the target sequential file.
Rgrds,
Abhi
Gen1715
Participant
Posts: 25
Joined: Mon Nov 05, 2012 5:42 am
Location: India

Post by Gen1715 »

Thanks Abhi, I already did that.. though while doing more R&D..This issue is narrowed down to what you can say precedential order of DS properties..

while reading it I mentioned start position at column level for each column and same column was propogated thoughout jobs

SEQ file --> Copy Stage --> SEQ file1,

at SEQ file1 I did defined delimiter as '|' , though the same start position was propogated from SEQ file till SEQ file1 resulting in overwrite of properties and I was getting same result as that of source file.

Anyways Thank you for your inputs. :)
Gaurav Martha
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Read all the input fields as Char data type. Replace the Copy stage with a Modify stage and apply string_trim() function to each field that you need trimmed.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Gen1715
Participant
Posts: 25
Joined: Mon Nov 05, 2012 5:42 am
Location: India

Post by Gen1715 »

Hi Ray,

Thank you for the reply, your approach is good :) , Having said that just wanted to make a quick point, It was sample data, just wanted to have POC that fixed length file can be read through sequential file in different columns.

As mentioned in earlier post while doing so, when same seq file propogated throughout the job and same start position for all columns also propogated throuout which was not letting "|" delimiter to do its work. As I removed start position at column level properties for all columns I was able to see delimited data, this can be resolved.
Gaurav Martha
Post Reply