ADF data flow expression to remove line feeds, carriage return, horizontal tab, vertical tab, new line

N2120 81 Reputation points
2022-12-03T00:43:02.697+00:00

Hello, I have a column from a table which has all the special characters . Can you please help me find a data flow expression to take off all the above special characters
I used regexreplace and replace() but output file still had the carriage return and line feeds.
pls advice asap.
thanks

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,486 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Suba Balaji 11,186 Reputation points
    2022-12-03T16:35:05.13+00:00

    Hi @N2120

    Thanks for the ask. Please check this Link in SO, which discusses the similar question.

    If you need further help on this please feel free to write back.

    Thanks


  2. MartinJaffer-MSFT 26,011 Reputation points
    2022-12-06T03:44:35.953+00:00

    Hello @N2120 could you please clarify how it is not working? What is it doing instead?

    I tried

    replace({_col0_}, '\t', 'TAB')  
    

    and saw results.

    replace({_col0_}, '\t', '')  
    

    became much harder to see. I have a hunch, a change is being made, but it isn't showing up well in the data preview. I could be wrong. That's why I started with 'TAB'.

    Another option is to use regexReplace because it can do all those characters at once. Both of the below showed results for me.

    regexReplace({_col0_}, `[\t\v\n\r]`, 'X')  
    
    regexReplace({_col0_}, `[\t\v\n\r]`, '')  
    

  3. Suba Balaji 11,186 Reputation points
    2022-12-06T03:47:29.517+00:00

    Hi @N2120 ,

    please find below the screenshot where i have tried to replace \t, \r, \n, \v with an empty string. It works fine for me. Please try and revert if you have questions.

    267632-screenshot-2022-12-06-at-91331-am.png


  4. N2120 81 Reputation points
    2022-12-08T04:35:39.44+00:00

    @Suba Balaji @MartinJaffer-MSFT
    I am at a loss to find alternate solution,
    will anything of these expressions work with replace() to recognize the carriage return '%0A' or '%0D'
    I also have a copy activity before this data flow, one of the columns of this output of copy activity is the source of the special characters.
    Is there a place in json code where I can do replace in the mapping of copy activity. Variable wont work for me as value will change in that column for each row. (my source system is SAP)
    pls advice.