Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: Numbers in Text File Output with Fixed Length

  1. #1
    Join Date
    Feb 2007
    Posts
    28

    Default Numbers in Text File Output with Fixed Length

    Hi All,
    If my input is '4', how can I have this output: ' 4' ?
    I know that using "000" as Format, I can get the '004'.

    Thanks in advance,
    Sergio

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    Put a space before the format?

    ' 0'

  3. #3
    Join Date
    Jul 2007
    Posts
    1,013

    Default

    I've had this problem before, getting a space before a number when not defining a format. It would seem like defining the format will get rid of it. You can use '#' or '#.#' if you don't need a specific format you want and you should be good...

    Cheers!

  4. #4
    Join Date
    May 2006
    Posts
    4,882

    Default

    I think the original poster wants some spaces before his number instead of leading zeroes ... something like "<space><space>4" instead of 004.

    Regards,
    Sven

  5. #5
    Join Date
    Jul 2007
    Posts
    1,013

    Default

    And you are probably right. It's just my childhood trauma from dealing with the unwanted spaces that did not allow me to understand the problem correctly.

  6. #6
    Join Date
    Feb 2007
    Posts
    28

    Default

    Thanks for all yours replays.

    Yes, Sven is right: I would like to have a fixed length column right alligned (i.e. with a variable number of leading spaces).

    Regards,
    Sergio

  7. #7
    Join Date
    Jul 2007
    Posts
    1,013

    Default

    Then your best bet would probably be a Javascript step and the padding functions:

    lpad(yourField.getString(), " ", 3)

    This will prepend "yourField" with as many spaces as needed to have it be 3 characters long.

    Cheers!
    Last edited by tdidomenico; 11-25-2008 at 10:10 AM. Reason: Typo

  8. #8
    Join Date
    Feb 2007
    Posts
    28

    Default

    If there is no way to do this in the Text File Output step, I'll do what you suggest.

    Thanks to All,
    Sergio

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.