Generate Sequential file Fixed format

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
mrekik
Participant
Posts: 12
Joined: Wed Sep 01, 2004 6:07 am

Generate Sequential file Fixed format

Post by mrekik »

Hi everybody
I need to generate sequential file with a fixed format.
Do you have any idea how can I do it ?


Regards.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

mrekik,

you mean a fixed-length format? If you use the sequential file stage and specifically remove the attributes for terminator, separator and quotes and add the null-padding then you will get a fixed-length output file.

Another possibility is to pipe the Px output file to the input file of a Server job, where it is much easier to specify a fixed-width output.
mrekik
Participant
Posts: 12
Joined: Wed Sep 01, 2004 6:07 am

Post by mrekik »

thank you
It works fine in a job server

Is it possible to do the some thing in the other sense.

I had generated this file :
me you 12
I Y 15

And my need is to transform it like this :
"me","you",12
"I","Y",15

Thanks for your help

Best regards
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

How about reading it in with a " " (space) as the separator and no quotes, then writing it out as a comma-delimited, quoted file? You don't even need a transform.
ds_is_fun
Premium Member
Premium Member
Posts: 194
Joined: Fri Jan 07, 2005 12:00 pm

Post by ds_is_fun »

In the "format" properties of the sequential file, choose filed defaults as
delimiter = comma , quote = double.
That should do it.
mrekik
Participant
Posts: 12
Joined: Wed Sep 01, 2004 6:07 am

Post by mrekik »

Thanks for your answers, But this not satisfy my need

My source file is fixed format (with space padding):
"a ""b " ....

And I want that the target file will be a non fixed format file with a comma separator but without padding ! :
"a","b", ....

Waiting for your help
best regards
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

mrekik,

please re-read your initial post, it states
I need to generate sequential file with a fixed format.
1. Does your source file actually contain the double-quote " characters, even though it is fixed-length? I will assume that you can now read this file correctly, using sequential file fixed length file definitions.
2. If you specify a TRANsform stage and do a simple TRIM() function on each padded CHAR field and write it to a sequential file defined with double-quote quote characters and a comma separator and default line termination you will end up with what you need.

If it doesn't work, please tell us whether the issue is with reading or writing. You can debug the read with a peek stage and the write with your favorite editor on UNIX.
mrekik
Participant
Posts: 12
Joined: Wed Sep 01, 2004 6:07 am

Post by mrekik »

Thank you for your response
I agree with you that my initial need was generating fixed format sequential file. Now, I am able to do it using a server job.

My second question was how to generate a non fixed format without space padding from a fixed format file. Using a transform stage to erase space padding is a good idea but my file contains 300 fields and it supposes that I must apply the trim() function to the 300 fields one by one ...
Is there another manner to do the same thing at the stage level, not at the fields level.

Regards
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

mrekik,

with 300 fields that would be a lot of work; but I think you might be able to do it without an explicit trim, depending on the data types (whether CHAR or VARCHAR) and the implicit trim when writing to a delimited output might work [test it to see]. If not, a server job which declares the whole row to be just one column will let you do a single TRIM function.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's easy (version 7.5) to propagate the Trim() function across all columns in the Transformer stage. Right mouse click and choose propagate expression, then fill in Trim($1) and select "entire expression".
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