Page 1 of 1

Generate Sequential file Fixed format

Posted: Fri Apr 08, 2005 3:36 am
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.

Posted: Fri Apr 08, 2005 5:37 am
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.

Posted: Fri Apr 08, 2005 9:41 am
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

Posted: Fri Apr 08, 2005 9:48 am
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.

Posted: Fri Apr 08, 2005 10:25 am
by ds_is_fun
In the "format" properties of the sequential file, choose filed defaults as
delimiter = comma , quote = double.
That should do it.

Posted: Mon Apr 11, 2005 1:54 am
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

Posted: Mon Apr 11, 2005 2:10 am
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.

Posted: Mon Apr 11, 2005 2:36 am
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

Posted: Mon Apr 11, 2005 3:37 am
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.

Posted: Mon Apr 11, 2005 5:29 am
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".