Whitespace in Fixed Width file

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
Ragunathan Gunasekaran
Participant
Posts: 247
Joined: Mon Jan 22, 2007 11:33 pm

Whitespace in Fixed Width file

Post by Ragunathan Gunasekaran »

Hi,

I am writing two columns with data type as decimal(16,2) followed by a charater field into a sequential file with the properties set as Record Delimiter = DOS style and Field Delimiter as None. I have removed the rest of record level and field level properties.

The code run is good but the data was not as expected. I could see a whitespace character at the start of the decimal fields.

Code: Select all

 00000000000100.00 00000000000001.00Other Banks
Any clue of how to get rid of this whitespace.


Note: The third character field is appearing as expected
Regards
Ragu
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

The whitespace you're seeing is in fact the placeholder for the sign of the number. By default, for a positive number it is a space, for a negative number it would be '-'. The default conversion from decimal to string returns a string that is two bytes longer than the length of the decimal: one byte for the sign, one byte for the decimal point '.'.

If you just wish to get rid of the space, you can use StripWhitespace() or one of the Trim() functions. Keep in mind that in doing so, negative numbers will still contain the '-' and would therefore be longer than non-negative numbers.

Alternatively, you could use Convert() to change the space to a plus symbol '+' and maintain the length integrity.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
Post Reply