reading a fixed-width flat file

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
kvnbabu
Participant
Posts: 16
Joined: Fri Nov 02, 2007 1:43 am
Location: Hyderabad

reading a fixed-width flat file

Post by kvnbabu »

[color=blue]
Hi,
I have fixed width flat file with only one column of size 618 char. I have no problems in reading the correct record, but there can be invalid records with either less or more than 618 char length. I want to identify these bad records and route them to a different file. Could you suggest me how I do this?

I defined a column with 1000 char as size, defined the delimiter '000' (which is equiavalent to no delimiter), but somehow its not working out.
[/color]
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Unless your fixed-width file has record delimiters (i.e. <cr><lf>) you cannot read it if some records have different lengths. So, does your file have line/record delimiters?
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

You could have a reject link from the file from which you are trying to read. The invalid records of variable length will sent to the reject link file.
kvnbabu
Participant
Posts: 16
Joined: Fri Nov 02, 2007 1:43 am
Location: Hyderabad

Post by kvnbabu »

[quote="ArndW"]Unless your fixed-width file has record delimiters (i.e. <cr><lf>) you cannot read it if some records have different lengths. So, does your file have line/record delimiters?[/quote]

New line character can be considered as end-of-record.
kvnbabu
Participant
Posts: 16
Joined: Fri Nov 02, 2007 1:43 am
Location: Hyderabad

Post by kvnbabu »

problem is not with rejecting them. but i am missing something, while reading the source files, the new line character also comes along the data and I am unable to strip it off.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since you have a terminator, what devidotcom suggested will work perfectly.

For the <lf> error - Have you declared the <cr><lf> in your sequential file stage definitions for the "record delimiter"?
kvnbabu
Participant
Posts: 16
Joined: Fri Nov 02, 2007 1:43 am
Location: Hyderabad

Post by kvnbabu »

devidotcom,

Please could you eloborate on what is to be done?

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

Post by ray.wurlod »

Look on the Stage properties of your Sequential File stage - is it set for UNIX-style, DOS-style or None? Look in the file itself, using a hex editor. How are lines in the file actually terminated?

Note that, if lines can be more, equal or less than 637 characters, then you do NOT have fixed-width format. Therefore you need to read using a single VarChar field, and test in a downstream Transformer stage whether the length is correct (and anything else you might want to test).

Server jobs do not support reject link on Sequential File stage; the advice from devidotcom relates only to parallel jobs.
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