Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to Convert XML file into CSV file using NIFI

Solved Go to solution

Re: How to Convert XML file into CSV file using NIFI

Guru

Hi @Nitin Damle

I'm assuming you got the flow working with the sample data and template I provided.

Can you provide an example of the desired csv output you are hoping to achieve from the cm_samples.xml file you provided? That would help me understand your end goal for the flow.

Thanks!

Re: How to Convert XML file into CSV file using NIFI

New Contributor

xmlsampleop.png


@Andrew Lim you can refercm_sample.txt


this image and file


Re: How to Convert XML file into CSV file using NIFI

Guru

Thanks for the information Nitin.

It seems like it would make sense to "clean up" your incoming XML using the TransformXML processor (https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache...) prior to ConvertRecord since there is data there like the header info that you don't care about for the CSV file. Additionally, could change the tag from `p` to its `name` attribute.

I haven't used the TransformXML processor before (or worked with XSLT files before). Take a look yourself and see if you think it could be a solution for you. I will try it out myself if I get the opportunity.

Re: How to Convert XML file into CSV file using NIFI

New Contributor

Hi Andrew,

I am not able to convert xml to csv as suggested by you to do the inverse of this. Could you please provide the nifi xml file so that I can upload the template and check.


Re: How to Convert XML file into CSV file using NIFI

Guru

Re: How to Convert XML file into CSV file using NIFI

New Contributor

Hi Andrew , this works for single xml but I have nested xml. How to convert nested xml to multiple csvs ?

Re: How to Convert XML file into CSV file using NIFI

New Contributor

@Andrew Lim Is there anything possible for nested xml to multiple csvs ?Attached is the nested xml file ad.xml

Re: How to Convert XML file into CSV file using NIFI

New Contributor

@Andrew Lim After importing it giving me this error

106511-csvtoxmlerror.png

Re: How to Convert XML file into CSV file using NIFI

New Contributor

Re: How to Convert XML file into CSV file using NIFI

New Contributor

You can use this NIFI Groovy processor that converts XML to CSV or AVRO

https://github.com/maxbback/nifi-xml


Don't have an account?
Coming from Hortonworks? Activate your account here