You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by "Nathamuni, Ramanujam" <RN...@tiaa.org> on 2016/08/25 22:16:09 UTC

NiFi processor to convert CSV to XML

Hello All,

I am looking for processor to convert  CSV file to XML. I looked at the processors available but I do not see one for CSV to XML? Is there any  workaround using other processor to this job? Or any can write new processor for this function?


Thanks,
Ram
*************************************************************************
This e-mail may contain confidential or privileged information.
If you are not the intended recipient, please notify the sender immediately and then delete it.

TIAA
*************************************************************************

Re: NiFi processor to convert CSV to XML

Posted by Matt Burgess <ma...@gmail.com>.
Ram,

You could use the ExecuteScript processor if you are comfortable with
scripting in Groovy, JavaScript, Jython, JRuby, or Lua. I have an
example [1] of reading in a file and splitting on a delimiter (like a
comma). If you use Groovy, you can leverage the MarkupBuilder [2] to
build XML. Please let me know if I can offer more guidance.

Regards,
Matt

[1] http://funnifi.blogspot.com/2016/02/executescript-explained-split-fields.html
[2] http://groovy-lang.org/processing-xml.html#_creating_xml

On Thu, Aug 25, 2016 at 6:16 PM, Nathamuni, Ramanujam
<RN...@tiaa.org> wrote:
> Hello All,
>
>
>
> I am looking for processor to convert  CSV file to XML. I looked at the
> processors available but I do not see one for CSV to XML? Is there any
> workaround using other processor to this job? Or any can write new processor
> for this function?
>
>
>
>
>
> Thanks,
>
> Ram
>
>
> *************************************************************************
> This e-mail may contain confidential or privileged information.
> If you are not the intended recipient, please notify the sender immediately
> and then delete it.
>
> TIAA
> *************************************************************************

Re: NiFi processor to convert CSV to XML

Posted by Andy LoPresto <al...@apache.org>.
Hi Ram,

NiFi does not currently have a ConvertCSVToXML processor. A couple suggestions:

* Use ExecuteScript processor with a small Groovy script which reads the CSV file (an attribute for the file path or with the file body as incoming flowfile content), parses the contents (a simple split on lines and then “,” should be sufficient), and then serializes to XML using `groovy.xml.MarkupBuilder` to format the output.
* Use an XLST transform with the TransformXML processor — I found this XSLT file which reads a CSV file and transforms it, but I cannot vouch for it [1].

[1] http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html <http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html>

Andy LoPresto
alopresto@apache.org
alopresto.apache@gmail.com
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Aug 25, 2016, at 3:16 PM, Nathamuni, Ramanujam <RN...@tiaa.org> wrote:
> 
> Hello All,
> 
> I am looking for processor to convert  CSV file to XML. I looked at the processors available but I do not see one for CSV to XML? Is there any  workaround using other processor to this job? Or any can write new processor for this function?
> 
> 
> Thanks,
> Ram
> 
> *************************************************************************
> This e-mail may contain confidential or privileged information.
> If you are not the intended recipient, please notify the sender immediately and then delete it.
> 
> TIAA
> *************************************************************************
>