Page 1 of 1

Files

PostPosted: Thu Aug 20, 2009 11:25 pm
by mahesh100
Hi,

I need to remove the padded spaces from one of the field.

File layout
two-char x(2)
three-char (3)
name x(35)
indicator 9(1)
indicator 9(1)

Input file

HEADER
IN,IND,INDIA                      ,1,0
GB,GBP,GREAT BRITAIN POUND        ,1,O
TRAILOR


(Remove all the extra spaces in the name field)
Output file:

header
IN,IND,INDIA,1,0
GB,GBP,GREAT BRITIAN POUND,1,0
TRAILOR

Please let me know of any thoughts.

Thanks,
Mahe

Re: Files

PostPosted: Thu Aug 20, 2009 11:38 pm
by mahesh100
INPUT FILE

HEADER
IN.IND,INDIAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ,0,1
GB,GBP,GREAT BRITAIN POUNDZZZZZZZZZZZZZZZZZZZZZZ,0,1
TRAILOR

zzzzzz --> Blanks

I want to remove all the blanks, So that when character comes to an end, delimit by , and remaining fields.

Thanks,
Mahesh

Re: Files

PostPosted: Fri Aug 21, 2009 6:12 am
by dick scherrer
Hello,

Suggest you become both familiar and comfortable with the the Code tag and the Preview function. Code will preserve alignment and improve readability and should be used for posting code, jcl, data, etc. The Preview function is used so you can see your post as it will appear to the forum rather than what is seen in the Reply editor. Make changes until the appearance is as you want it, then Submit. Do not forget to Submit as the editing will be lost. . .

The sample input data does not match the "file layout". Is the input delimited?

Re: Files

PostPosted: Fri Aug 21, 2009 12:21 pm
by mahesh100
Hi,

Yes, The file is delimited by ,

Thanks,
Mahe

Re: Files

PostPosted: Sat Aug 22, 2009 12:49 am
by dick scherrer
Hello,

Then you could UNSTRING the data into separate fields, calculate the length of the name field data, and STRING the individual fields back into a single field for output.

Re: Files

PostPosted: Thu Aug 27, 2009 2:46 pm
by mahesh100
Hi,

I was holiday.
I feel even if you string the individual field back into the single field , the output field will still hold the spaces as the output field is declared as x(40).

Probably i could not get your point.

Thanks,
Mahe

Re: Files

PostPosted: Fri Aug 28, 2009 3:56 am
by dick scherrer
Welcome back. . . :)

Yes, there will still be 40 bytes - they do not go away. . . However, after the unstring/string (if done properly), the embedded blanks will be removed.

Re: Files

PostPosted: Mon Aug 31, 2009 6:05 pm
by mahesh100
Dick,

Thanks for the info... But still i am thinking on it ,how to use that ...

If any help on that will be great...
I was thinking on the Inspect as well.

Thanks,
Mahe

Re: Files

PostPosted: Tue Sep 01, 2009 3:03 am
by dick scherrer
Hello,

Unless i completely misunderstand what you want to do, inspect will not be of any use. . .

But still i am thinking on it ,how to use that ...
If any help on that will be great...
What is not clear? The input is a "not quite usable" delimited string (because of embedded spaces). If the string is unstrung into several variables, the meaningful length of each component can be calculated (field length minus trailing spaces), and then the values can be strung back together using reference modification, eliminating the unwanted trailing spaces.