Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Altering String with JavaScript

  1. #1
    Join Date
    Sep 2005

    Default Altering String with JavaScript


    I load data from a text file, which works pretty well. One field contains a number in the format "+000012,4567", which is not correct (Oracle doesnÂ't like the "+"). I load this field as a string, but now I want to

    1. eliminate the "+" from the string and
    2. convert the string to a number.

    I found the javascript function "replace", but what I do not know is how to use the "Java Script Value"-Transform-Step. How can I assign the value of a field to a java script variable, how can I write the result back to the fiel? Maybe a screenshot would help me most.

    Before using spoon I was used to work with external tables. A replace function could easily be integrated in the external table DDL.

    I would be very thankful if you could help me with this problem.

    Thx in advance.


  2. #2
    Join Date
    Nov 1999

    Default RE: Altering String with JavaScript

    Hi Dominik,

    You can do it directly in Text File Input by adding the + to the format mask, in your case:


    or perhaps '+'#.# will also work.

    As for the replace function:

    field.replace("+", "") would do the trick. The value is changed directly on the field value.
    For more information on JavaScript, see the Weekly Kettle Tip on JavaScrip from a few weeks ago on this very forum.



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.