Reading Fixed length record 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
mydsworld
Participant
Posts: 321
Joined: Thu Sep 07, 2006 3:55 am

Reading Fixed length record file

Post by mydsworld »

Hi,

I have the following fixed length input :

Input :

Q0009814 TEST DATA 500000P

I would like to extract 3 columns from the below fixed length record file.

Col1 - Q0009814
Col2 - TEST DATA
Col3 - 500000P

and I want to mention my Record Length = 40 and length of Col1,Col2,Col3 are 18,15,7 respectively.

How do I set that in Sequential file stage.I can find 'Record Length' (will that be 'fixed' or 40), but not 'Field Length'.

Thanks
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

read the whol record as char (40) and then concatenate into three columns.
mydsworld
Participant
Posts: 321
Joined: Thu Sep 07, 2006 3:55 am

Post by mydsworld »

How to do that
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

instead of three, just define one column as char (40).

Define delimiter and quote character as none and read your source file.
mydsworld
Participant
Posts: 321
Joined: Thu Sep 07, 2006 3:55 am

Post by mydsworld »

After that how to separate them into three fixed width columns
sgubba
Participant
Posts: 30
Joined: Wed Apr 16, 2008 11:06 am

How to read fixed width from a schema file

Post by sgubba »

I want to know if we can read a fixed widht file using the schema file ..........my problem is i get data from different locations and the schema for each of them is different.......i want to read data from any source just by changing the schema file ....i could do that for a comma delimited file ........i want to know if we can do that for a fixed width file
mydsworld
Participant
Posts: 321
Joined: Thu Sep 07, 2006 3:55 am

Post by mydsworld »

How do we handle data from different locations (with different metadata) with schema files.Do we have schema file as parameter or schema file with RCP.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Re: How to read fixed width from a schema file

Post by Krazykoolrohit »

sgubba wrote:I want to know if we can read a fixed widht file using the schema file ..........my problem is i get data from different locations and the schema for each of them is different.......i want to read data from any source just by changing the schema file ....i could do that for a comma delimited file ........i want to know if we can do that for a fixed width file
you will have to read all the files in seperate stages. In case you want to process them in same job, you will have to be more specific. Send us examples of 2-3 files that you will get so that we can explaind the solution to you.

there is no stage that allows that or schema cannot be read from any text file. you will have to logically implement it
sgubba
Participant
Posts: 30
Joined: Wed Apr 16, 2008 11:06 am

Re: Reading Fixed length record file

Post by sgubba »

Yeah i am able to do it now...Assume In a fixed file lenght format column NAME is at position from 1-10 for one source data file ....and the same column "NAME" is at position 200-210 for another source data file ....i should be able to read any kind of source data file by just changing the schema file.I am using a column import to break a record into differnt columns by using schema file ....i was able to do it by field delimiter ....now i am able to read it for a fixed lenght filed format



mydsworld wrote:Hi,

I have the following fixed length input :

Input :

Q0009814 TEST DATA 500000P

I would like to extract 3 columns from the below fixed length record file.

Col1 - Q0009814
Col2 - TEST DATA
Col3 - 500000P

and I want to mention my Record Length = 40 and length of Col1,Col2,Col3 are 18,15,7 respectively.

How do I set that in Sequential file stage.I can find 'Record Length' (will that be 'fixed' or 40), but not 'Field Length'.

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

As you import the table definition check the "Fixed width" check box on the Format tab, then enter 18,15,7 in the column widths field. Select the Define tab and note that the widths are recorded as "Display width". Make any other required changes, such as addition of data elements and descriptions, and click OK to save the table definition into the Repository.
Use it from there.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply