Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Problem with type conversion

  1. #1
    Join Date
    Aug 2007

    Default Problem with type conversion


    I'm trying to integrate data in which some numbers are defined as followed:
    + 2056,23
    + 1,66
    - 523,008

    Problem is that text input file step doesn't support + xxxx.
    So I read the row as a String and if the String contains + I replace it.
    After I convert it in number or integer.

    Following Matt advices I use a ModJS Step:
    value_num = value.Clone().
    replace(" ", "").replace("+", "");

    and a select value step to change format to Integer.

    It works fine when I use a generate step but not when input come from a text input file.
    Number retrieved is always zero??

    I've attached a sample of the transformation and a sample file.
    Any idea?
    Thanks in advance for your Help

    Attached Files Attached Files

  2. #2
    Join Date
    May 2006


    In the javascript step use:

    value_num = value.Clone().replace(",", ".").replace(" ", "");

    instead of yours... the problem is not in the + sign but in
    1) the "," ... probably your locale
    2) the spaces after the sign

    Then in your select values use a conversion to Number instead of to Integer... the default it seems when a value can't be converted is 0. A number with decimal places can not be converted to an integer.

    As additional use calculator e.g. to round off.


  3. #3
    Join Date
    Aug 2007


    thanks very much you Sven, it works now.


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.