Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: How do I replace a value of a string

  1. #1
    Join Date
    Aug 2009
    Posts
    9

    Default How do I replace a value of a string

    Good day to all,

    I need advise to perform this task.

    I have this input values 0000666{, 0000024I, 0001104A and I need to replace the last character (which is an overpunch character) with 0, 9 and 1 respectively so that it the output will become 00006660, 00000249 and 00011041. Is there a task that can perform this operation or how is it done in Java (I'm not familiar with java yet)

    many thanks,

  2. #2
    Join Date
    Feb 2009
    Posts
    296

    Default

    How do you like the Step "Replace in String" so far?
    Fabian,
    doing ETL with his hands bound on his back

  3. #3
    Join Date
    Aug 2009
    Posts
    9

    Default

    Replace in String step? where is it located? what version? I'm using ver 3.1.2. thanks

  4. #4
    Join Date
    Feb 2009
    Posts
    296

    Default

    It's one of the new and nifty steps in Version 3.2.0 - you should check it out if you're free to upgrade.

    If you'll have to stick with 3.1 you're stuck with the modified java script step. This is NOT Java.
    Fabian,
    doing ETL with his hands bound on his back

  5. #5
    Join Date
    Aug 2009
    Posts
    9

    Default

    How do I write this in Modified java script?

    Many Thanks

  6. #6
    Join Date
    Feb 2009
    Posts
    321

    Lightbulb

    use the function substr(var, pos,length) for get the character to covert and then use "if" senteces.
    example

    var my_variable = 'hell6';
    var char_transco = 'o';
    aux = substr(my_variable,4,1);

    if (aux == '6')
    my_variable = substr(my_variable,0,4) + char_transco;


    this return the string 'hello'.

    use this when you know the length of the field. if the fields have variable length, you must find the length before.

    good luck

  7. #7
    Join Date
    Aug 2009
    Posts
    9

    Default

    Many Thanks Hernan If its not too much can you also teach me how to use the Shell Command Script step of Pentaho. I tried using that step by calling a .bat file but nothing happens. PIt only tells me that the step was finished but it does not executed the batch file. But when I run the batch file using the console it is working. I don't know where's the problem.

    Again Thanks for your help.

  8. #8
    Join Date
    Feb 2009
    Posts
    321

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.