- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to Convert XML file into CSV file using NIFI
- Labels:
-
Apache NiFi
Created 02-14-2019 05:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Created 02-14-2019 02:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created 02-14-2019 02:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created 02-15-2019 05:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Andrew Lim
can you please upload the template here i have tried to upload template given in link but it throwing error
Created 02-15-2019 03:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Created 02-20-2019 04:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Nitin Damle
It would be helpful if you selected "Reply" to each of my comments instead of adding new Answers, which makes the readability of this question more difficult. Understandably, the "Reply" link is very small and hard to see.
Are you modifying the template prior to uploading it into NiFi? That was the issue in the other HCC article you referenced (https://community.hortonworks.com/questions/226390/nifi-18-error-updateattribute-is-not-known-to-thi...). Because the template was malformed, it gave that error.
Created 02-25-2019 06:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Andrew Lim can you upload the template for XML to CSV with sample data .
Created 02-25-2019 08:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Nitin Damle
Here is the XML to CSV template: convert-xml-to-csv.xml
Here is the sample XML file to use: users.xml
If you find these helpful, please "Accept" my original answer from February 14th as this template is the implementation of what I suggested to do.
Created 02-25-2019 08:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One thing, I wanted to note. For the XMLReader controller service (https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services...), I needed to set the Expect Records as Array property to "true".
Created 02-27-2019 05:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @Andrew Lim
Created 02-27-2019 10:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Andrew Lim , i am getting header only not data
i attached my schema and xml pls let me know where i am going wrong