Page 1 of 1

Reading Fixed length record file

Posted: Mon Jun 09, 2008 1:29 pm
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

Posted: Mon Jun 09, 2008 1:43 pm
by Krazykoolrohit
read the whol record as char (40) and then concatenate into three columns.

Posted: Mon Jun 09, 2008 1:49 pm
by mydsworld
How to do that

Posted: Mon Jun 09, 2008 2:00 pm
by Krazykoolrohit
instead of three, just define one column as char (40).

Define delimiter and quote character as none and read your source file.

Posted: Mon Jun 09, 2008 2:04 pm
by mydsworld
After that how to separate them into three fixed width columns

How to read fixed width from a schema file

Posted: Mon Jun 09, 2008 3:57 pm
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

Posted: Mon Jun 09, 2008 7:23 pm
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.

Re: How to read fixed width from a schema file

Posted: Wed Jun 11, 2008 3:02 pm
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

Re: Reading Fixed length record file

Posted: Wed Jun 11, 2008 7:05 pm
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

Posted: Wed Jun 11, 2008 9:05 pm
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.