Support Questions

Find answers, ask questions, and share your expertise

Convert JSON to CSV using Nifi

avatar

I would like to convert a JSON file to CSV formatted file which is nested and also have more than 100 records using Apache nifi in HDF. I'm new to Nifi, can some one please help me like what processors to be used and how to configure them?

Thanks,

Rahul

8 REPLIES 8

avatar
Master Guru

Use EvaluateJsonPath Field Style is

totalNonHeap =>$.systemDiagnostics.aggregateSnapshot.totalNonHeap

status => $.systemDiagnostics.aggregateSnapshot.status

country => $.country

Then ReplaceText to format as CSV

${'status'},'${'country'}','${'totalNonHeap'}'

Then PutFile to write a file

http://jsonpath.com/

http://goessner.net/articles/JsonPath/

avatar

Thanks for responding so quick. In a situation, if i have a json file I want to convert to csv file using these two processors. can you please help me in configuring these processors(i mean how do we set JSON path) and also please demonstrate with an example

avatar
Master Guru

avatar

Thats really helpful. Thanks. So at the end do we need to use MergeContent processor to get that CSV records all in one file.?

avatar

Hi,

can you please help with the mergecontent processor to merge all the csv files into single csv file.

Thanks

avatar
Master Guru

mergecontent will put all the csv records in one file

9047-merge.png

done

avatar

Hi

I'm able to zip all those into a Zip file.

but i'm trying to merge all those csv files into a single CSV file like an Excel sheet.

Thanks

avatar
New Contributor

How to configure merge record inorder to merge the multiple flowfile having content as

a|1  and the other flow files like b|2 ..etc

I need to merge them and get it as

a|1

b|2

where as i get a|1b|2