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.

Using Nifi api data Converisons from json to csv

Using Nifi api data Converisons from json to csv

New Contributor

Hi All,

 

I have been working in with the Nifi-1.9.2 and i have been facing the issue regarding conversion of json data to csv. The following is the json data we have

{"search:{},"matched":null,"returned":27,"result":[{"device":"abc","index":"1","index_label":null,"presentation":2,"field_names":["ctime","data"],"data":[[1570006500,67.67],[1570006800,66.15],[1570007100,66.24],[1570007400,67.41]]}]}

Here i need the csv as below:

device,index,index_label,presentation,ctime,data

abc,1,null,2,1570006500,67.67

abc,1,null,2,1570006800,66.15

abc,1,null,2,1570007100,66.24

abc,1,null,2,1570007400,67.41

I used the below processors:

gethttp --> splitjson --> convertrecord --> puts3object

in convertrecord: i used

jsontreerecord

csvsetrecord

in avroschemaregistry i used the below schema

{
"type" : "record",
"namespace" : "data",
"name" : "sample",
"fields" : [
{"name" : "device" , "type" : "string"},
{"name" : "index" , "type" : "int"},
{"name" : "index_label" , "type" : "string"},
{"name" : "presentation", "type" : "int"},
{"name": "field_names","type": { "type": "array", "items": {"name": "field_record","type": "record","fields": [ {"name": "ctime","type": "int" }, {"name": "data","type": "int" }] }}}]}

Thanks

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