Support Questions

Find answers, ask questions, and share your expertise

Nifi ReplaceText, escapeCsv does not return anything

avatar
Explorer

Hello!

The general task is to transform xml to csv

For this aim I created following pipeline:

       FLOW.png

Source xml content is:

     <Email E-mail="AR-BIK@GMAIL.COM"> <Data GRN="3214600023849" Date="2024-07-28"></Data></Email>

Parameters of EvaluateXPath are:

  EvaluateXPath.png

      ReplaceText parameters:

   ReplaceText.png

   Attribute grn successfully produced with expected value:

    Attributes.png

But value "3214600023849" is not translated to csv. Only ; delimiter.

Output.png

 

Encoding is UTF-8 

What am I doing wrong?

1 ACCEPTED SOLUTION

avatar
Master Mentor

@AndreyDE 

Post your EvaluateXPath processor you have a FlowFile that now has a FlowFile Attribute "/grn" with a value of "3214600023849".  

In ReplaceText, it appears you intent is to replace the entire content of the FlowFile with the value returned by the NiFi Expression Language (NEL) statement:  

${grn:escapeCsv()};

Your expression language statement grabs the value from FlowFile Attribute "grn", passes it the escapeCsv NEL function and then appends a ";" to the returned result.

Problem 1 is your FlowFile has no attribute "grn", it has an attribute "/grn"
Since "/grn" contains special character "/", it will need to be quoted in the NEL statement as follows:

${"/grn":escapeCsv()};

 reference: Structure of a NiFi Expression

Above would output content with:

3214600023849;

This content would not require being surrounded by quotes under RFC 4180

 reference: escapeCSV function 

 

Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

View solution in original post

2 REPLIES 2

avatar
Master Mentor

@AndreyDE 

Post your EvaluateXPath processor you have a FlowFile that now has a FlowFile Attribute "/grn" with a value of "3214600023849".  

In ReplaceText, it appears you intent is to replace the entire content of the FlowFile with the value returned by the NiFi Expression Language (NEL) statement:  

${grn:escapeCsv()};

Your expression language statement grabs the value from FlowFile Attribute "grn", passes it the escapeCsv NEL function and then appends a ";" to the returned result.

Problem 1 is your FlowFile has no attribute "grn", it has an attribute "/grn"
Since "/grn" contains special character "/", it will need to be quoted in the NEL statement as follows:

${"/grn":escapeCsv()};

 reference: Structure of a NiFi Expression

Above would output content with:

3214600023849;

This content would not require being surrounded by quotes under RFC 4180

 reference: escapeCSV function 

 

Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

avatar
Explorer

Thank you, the matter was in "/", indeed ))