how to handle newline character reading from sequential file

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

kirankumarreddydesireddy
Participant
Posts: 110
Joined: Mon Jan 11, 2010 4:22 am

Post by kirankumarreddydesireddy »

pandeesh wrote:Can your please elaborate?
As you told, the new line character is there in the last field. then what about the record delimiter?
Can you please post your actual input data and mention what's your required output?
Please find the below sample input,

Name|EmpID|Description
Ravi|001|This is Ravi
Raj
esh|002|This is
Rajesh
Raghu|003|This is Raghu

Here you can find there exists a new line character in the first and last field for the second record.However to handle newline in the "name" field,if I enable "Contains Terminators" to yes and apply Convert(CHAR(13):CHAR(10),"",YourField) in the transformer,it has handled newline character for the first field and the ouput will be

Rajesh|002|This is
Rajesh

How to handle the newline character for the field "Description" which is the last one in our record.



Thanks
Kiran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The same way. However, it's unclear from your post if you tried repeating the Convert for the Description field as well... did you?
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Craig,
It seems it's not possible to set YES to contains terminator for the last field(Description here).
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

kirankumarreddydesireddy wrote: Please find the below sample input,

Name|EmpID|Description
Ravi|001|This is Ravi
Raj
esh|002|This is
Rajesh
Raghu|003|This is Raghu

Thanks
Kiran
Why the output should not be:

Code: Select all

Ravi|001|This is Ravi
Rajesh|002|This is
RajeshRaghu|003|This is Raghu
i guess there's a flaw in the logic.
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or a flaw in your understanding. :wink:

Terminators in the final column must be Quoted to be recognized as data, meaning inside the quoted string that is the final column's data.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

After marking Description field as quoted one, i am getting the below output:

Code: Select all

Ravi|001|This is Ravi
Rajesh|002|This is
RajeshRaghu|003|This is Raghu 
i have applied Convert() for all the 3 fields in transformer.
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well... first off this isn't your topic and thus not your data, only the data that you've created in what you assume is a match for the original poster's data. Secondly, have you validated what you have as the 'terminator' inside that last field? Perhaps you should only be converting one of the two characters in question rather than the pair. There's no way for us to know what you've got there and this is further complicated by the OP being on Windows with you on a UNIX server.

While I appreciate your enthusiasm, why not wait for the post's owner to come back and say what does or doesn't work for them rather than overrunning their topic with all of your experimentation?
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Sure Craig!
pandeeswaran
kirankumarreddydesireddy
Participant
Posts: 110
Joined: Mon Jan 11, 2010 4:22 am

Post by kirankumarreddydesireddy »

chulett wrote:Terminators in the final column must be Quoted to be recognized as data, meaning inside the quoted string that is the final column's data. ...
Hi Chulett,

I didnot get exactly what you meant by "Terminators in the final column must be Quoted".

Firstly my input data to the sequential file :

Name|EmpID|Description
Ravi|001|This is Ravi
Raj
esh|002|This is
Rajesh
Raghu|003|This is Raghu

My output should be :

Name|EmpID|Description
Ravi|001|This is Ravi
Rajesh|002|This is Rajesh
Raghu|003|This is Raghu


What we did to achieve this :

To handle newline in the "name" field,if we enable "Contains Terminators" to yes and apply Convert(CHAR(13):CHAR(10),"",Name) in the transformer,it has handled newline character for the first field and the ouput will be :

Name|EmpID|Description
Ravi|001|This is Ravi
Rajesh|002|This is
Rajesh
Raghu|003|This is Raghu

My concern here is how to handle the new line character in the "Description" field?

What we did was:

if we enable "Contains Terminators" to yes,It was prompting that

Column "Description" cannot cantain a non-qouted terminator because it is the last column of a delimited sequential file"

if we enable "Contains Terminators" to Quoted and apply Convert(CHAR(13):CHAR(10),"",Description) in the transformer,


the output will be :

Name|EmpID|Description
Ravi|001|This is Ravi
Rajesh|002|This is
Rajesh Raghu|003|This is Raghu


We are not sure what you meant by exactly "Terminators in the final column must be Quoted".Is that something the actual data in Description column should be quoted?

i.e

Name|EmpID|Description
Ravi|001|This is Ravi
Raj
esh|002|"This is
Rajesh"
Raghu|003|This is Raghu


It didnot work as well.



Thanks
Kiran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kirankumarreddydesireddy wrote:We are not sure what you meant by exactly "Terminators in the final column must be Quoted".Is that something the actual data in Description column should be quoted?
Yes, that is what I meant and that is what allows the stage to differentiate between termintors "in the data" and the real one at the end of the record. If that's not working for you, I'd suggest a couple of things. One would be (as mentioned above) to verify the actual character that is in the description column. It may not be a CR/LF pair. Use a hex editor or an octal dump to verify and adjust your Convert accordingly. Failing that, I'd suggest contacting your official support provider.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply