Hello,

Regarding the CsvToJson template, here is what is happening...

1) GenerateFlowFile produces a FlowFile to simulate some data

2) ReplaceText sets the content of that flow file to "a,b,c,d" to represent
and example CSV line

Steps 1 and 2 are just simulating data that would really come from
somewhere else.

3) ExtractText applies a regular expression to the FlowFile to extract the
columns of the CSV...

In this case there is an attribute added to the processor called "csv" with
a value of (.+),(.+),(.+),(.+)

After the FlowFile passes through this processor it will have added
attributes:

csv.1 = a
csv.2 = b
csv.3 = c
csv.4 = d

4) ReplaceText uses those new attributes to build a new JSON document by
setting the replacement value to:

{
 "field1" : "${csv.1}",
 "field2" : "${csv.2}",
 "field3" : "${csv.3}",
 "field4" : "${csv.4}"
}

5) UpdateAttribute is not doing anything in this example, it is just a
place holder to send the results of step 4 somewhere and end the flow, you
would replace this with whatever you want to do with your JSON.

-Bryan


On Tue, May 3, 2016 at 4:26 AM, idioma <[email protected]> wrote:

> I am comment on my own question, just to clarify one aspect of the existing
> template. I am not sure why we need ExtractText between the first
> ReplaceText and the one that in the flow comes before UpdateAttribute? I am
> not sure I have fully understood the flow, what is the actual value for
> that
> step?
>
> Thank you so much for your help.
>
>
>
> --
> View this message in context:
> http://apache-nifi-developer-list.39713.n7.nabble.com/Using-the-template-cvs-to-json-to-convert-dsv-files-into-json-format-a-few-questions-tp9738p9782.html
> Sent from the Apache NiFi Developer List mailing list archive at
> Nabble.com.
>

Reply via email to