Skip to main content
nitindamle_123
Silver ⭐️⭐️⭐️
February 14, 2019
Solved

How to Convert XML file into CSV file using NIFI

i have XML files about 1-2 GB i want it to convert into CSV format using apache nifi.

so that i can process CSV for joining the two csv.

alim
alimAnswer
Gold ⭐️
February 14, 2019

Hi @Nitin Damle

You can use the ConvertRecord processor (with XMLReader/CSVRecordSetWriter controller services). I have an article here that shows CSV to XML (with CSVReader/XMLRecordSetWriter controller services), so you just need to do the inverse of that record transformation:

https://community.hortonworks.com/content/kbentry/199310/xml-record-writer-in-apache-nifi-170.html

-Andrew

22 replies

alim
Gold ⭐️
alimAnswer
Gold ⭐️
February 14, 2019

Hi @Nitin Damle

You can use the ConvertRecord processor (with XMLReader/CSVRecordSetWriter controller services). I have an article here that shows CSV to XML (with CSVReader/XMLRecordSetWriter controller services), so you just need to do the inverse of that record transformation:

https://community.hortonworks.com/content/kbentry/199310/xml-record-writer-in-apache-nifi-170.html

-Andrew

Translate
nitindamle_123
Silver ⭐️⭐️⭐️
February 15, 2019

@Andrew Lim

can you please upload the template here i have tried to upload template given in link but it throwing error

Translate
alim
Gold ⭐️
Gold ⭐️
February 15, 2019

@Nitin Damle

convert-cvs-to-xml.xml

If you are still having problems uploading the template, can you confirm what version of NiFi you are on? I just did a test in NiFi 1.8.0 and the upload was successful.

Translate
nitindamle_123
Silver ⭐️⭐️⭐️
February 20, 2019

@Andrew Lim After importing it giving me this error

106511-csvtoxmlerror.png

Translate
nitindamle_123
Silver ⭐️⭐️⭐️
February 20, 2019
max_boreback
Silver ⭐️⭐️⭐️
February 23, 2019

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

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


Translate
nitindamle_123
Silver ⭐️⭐️⭐️
February 25, 2019

@Max Börebäck can you upload the template here

Translate
maxbback
Silver ⭐️⭐️
February 1, 2020

I have uploaded a NiFi example template on https://github.com/maxbback/nifi-xml

Translate
maxbback
Silver ⭐️⭐️
January 13, 2020

Depending on the complexity

But one option is to use the built in converters Another Option is to use this groovy script

 

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

 

Translate