Handling Line Terminator's

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Handling Line Terminator's

Post by naren6876 »

I have a input file which is fixed width of 100.But, sometimes i am receiving it with Line Terminator and sometimes without any Line terminator.How can i handle this?.

I would be grateful If anyone could shed some light on this?.

Thanks in advance.
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Re: Handling Line Terminator's

Post by ogmios »

First if it's possible to get the source fixed, fix it.

For the rest there are numerous options:

1) pre-process the files outside of DataStage, call a script before running the job that puts the line terminators right.
2) Use something as Sequential file -> transformer -> ... in which you read lines of 101 bytes long and you substring the first 100... then you do regular processing
3) In the sequential file stage switch of line termination handling, add a column for the line terminator. Then in the columns tab of seqential file stage go to the right (the options you need are normally not visible). There you will find an action to be performed on missing columns. Don't know the correct option to choose out of my head. Disadvantage of this is that it will leave warnings in your job log.

Ogmios
In theory there's no difference between theory and practice. In practice there is.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Should the file be fixed width with end of line terminators or no end of line terminators just 100 characters per "record"? There's a big difference. I don't possibly see how you can fix a file under either circumstance.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Post by ogmios »

kcbland wrote:Should the file be fixed width with end of line terminators or no end of line terminators just 100 characters per "record"? There's a big difference. I don't possibly see how you can fix a file under either circumstance.
I assumed he means 100 characters per line fixed width as input but e.g. that because of different sources (and ftp transmissions) in one set of he will either get or not get line terminators. So essentially he just was to have the first 100 characters per line.

Ogmios
In theory there's no difference between theory and practice. In practice there is.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Are there supposed to be line terminators or not?

The first 100 chars of each line means that each line has a terminator, because you are saying LINE.

If there are just 100 char blocks of data, then there is no concept of a LINE, thus a line terminator will mess things up.

Either you have line terminators or not. You can't arbitrarily remove a line terminator (LF) because that is assuming that it is an extraneous character and removing will not shift data. I'm not willing to take a position on doing that.

Per the original post:
sometimes i am receiving it with Line Terminator and sometimes without any Line terminator
No line terminator to me means that two "lines" run together continuously as 100 character blocks.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Post by naren6876 »

Actually iam expecting a file with Line Terminator either fixed width or variable width.So,How can i put a Line terminator if I dont receive it in the file?
kcbland wrote:Should the file be fixed width with end of line terminators or no end of line terminators just 100 characters per "record"? There's a big difference. I don't possibly see how you can fix a file under either circumstance.
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Post by ogmios »

naren6876 wrote:Actually iam expecting a file with Line Terminator either fixed width or variable width.So,How can i put a Line terminator if I dont receive it in the file?
No go for that... you have different source formats so use diferent DataStage jobs.
In theory there's no difference between theory and practice. In practice there is.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

naren6876 wrote:Actually iam expecting a file with Line Terminator either fixed width or variable width.So,How can i put a Line terminator if I dont receive it in the file?
Then 2 lines run together as 1 line? How do you know where the first derived line is separate from the second if they're variable width?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ratikmishra1
Charter Member
Charter Member
Posts: 42
Joined: Wed Aug 18, 2004 2:49 pm

Post by ratikmishra1 »

Dos this file has a header or trailer record that has the record count in the file? If yes, you may think of writing a shell script to check the total bytes of the file with the computed total bytes for size 100 and for size 101. And see which one matches.

Then call the fix_100 or fix_101 job to do the processing.
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Post by naren6876 »

If it is variable width , Under the Format tab of sequential file If I specify the delimiter as 013 and Line Termination as UNIX style, then I can see all the LINE's.


kcbland wrote:
naren6876 wrote:Actually iam expecting a file with Line Terminator either fixed width or variable width.So,How can i put a Line terminator if I dont receive it in the file?
Then 2 lines run together as 1 line? How do you know where the first derived line is separate from the second if they're variable width?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Open the Columns grid, scroll right and find where you can set the "column contains line terminators" rule. This should allow you to handle any intermediate line terminator characters in the data.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Post by naren6876 »

Hi ray,
It doesn't solve my problem.

Is there any way to find out a file has Line Termination of UNIX style or DOS style or None.?

I would be grateful if anyone could shed some light on this.
Thanks in advance.
ray.wurlod wrote:Open the Columns grid, scroll right and find where you can set the "column contains line terminators" rule. This should allow you to handle any intermediate line terminator characters in the data. ...
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

I think Ray neglected to read the entire discussion, otherwise he hopefully wouldn't have given a bad answer. :cry:
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Ultimately the answer to the original problem is to force the supplier of the file to be consistent in the style of delivery. Other than that, test the fnal byte (prior to any end-of-file indicator) of the file to determine whether it is a line termination character, if it isn't then you have an unterminated record structure. Based on this outcome, start either a job that handles terminated records or a job that handles unterminated records. You can not do both in the one job, since line termination is a stage property that can not be parameterized.

It was the apostrophe that made me write a bad answer! :twisted:
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