Page 1 of 1

reading a fixed-width flat file

Posted: Thu Jan 03, 2008 5:28 am
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]

Posted: Thu Jan 03, 2008 5:40 am
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?

Posted: Thu Jan 03, 2008 5:44 am
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.

Posted: Thu Jan 03, 2008 5:45 am
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.

Posted: Thu Jan 03, 2008 6:02 am
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.

Posted: Thu Jan 03, 2008 6:16 am
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"?

Posted: Thu Jan 03, 2008 6:27 am
by kvnbabu
devidotcom,

Please could you eloborate on what is to be done?

Thanks

Posted: Thu Jan 03, 2008 2:34 pm
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.