Customer Portal

Newbie 'Replace' Question

Comments 4

  • Avatar
    imriskal
    0
    Comment actions Permalink
    Hi Dave,

    Could you please share your graph and a sample of input file throwing the error? I would like to see the error you get for myself.

    A general advice I can give you right away is that you should be careful about the second argument of replace function. It is not a string as it might seem, it is a regular expression. So for example special characters should be escaped. See the documentation for replace function http://doc.cloveretl.com/documentation/ ... l2-replace

    Thanks.
  • Avatar
    daveinhants
    0
    Comment actions Permalink
    Hi Lubos,

    Thanks for your help.

    Attached you can see the graph and the transformation I have tried to apply that failed.

    Then I have shown the graph processing successfully without that Reformat box and an excerpt of the data that shows the field I'm trying to apply the transformation on.

    The strange thing is I used the same syntax to apply a similar transformation on another field (replacing - with / in a string) and it worked!

    Dave
  • Avatar
    daveinhants
    0
    Comment actions Permalink
    Ultimately I will want to replace several different values with new ones (Y, N, NA, blank etc). Would I need to have some kind of if, then, else statement to achieve this?

    Sorry if this is too basic I'm a glorified user not a developer! :-)

    Thanks, Dave
  • Avatar
    slechtaj
    0
    Comment actions Permalink
    Hi Dave,

    I think that Lubos wanted to take a look at the GRF file (or even better the whole project including the source CSV file). To me, it doesn't seem there is actually a problem with the replace function. The thing is the issue might have been caused by several other reasons. In order to find this out I would need to see the long and/or the GRF file.

    Regarding the if - else (or switch - case) statements, it really depends on the particular case. Sometimes even one smart regular expression can handle multiple (or all) different cases.

Please sign in to leave a comment.