Support Questions
Find answers, ask questions, and share your expertise

Convert JSON to CSV using Nifi

Highlighted

Convert JSON to CSV using Nifi

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
Highlighted

Re: Convert JSON to CSV using Nifi

Super 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/

Highlighted

Re: Convert JSON to CSV using Nifi

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

Highlighted

Re: Convert JSON to CSV using Nifi

Super Guru
Highlighted

Re: Convert JSON to CSV using Nifi

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

Highlighted

Re: Convert JSON to CSV using Nifi

Hi,

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

Thanks

Highlighted

Re: Convert JSON to CSV using Nifi

Super Guru

mergecontent will put all the csv records in one file

9047-merge.png

done

Highlighted

Re: Convert JSON to CSV using Nifi

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

Highlighted

Re: Convert JSON to CSV using Nifi

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

Don't have an account?