【发布时间】:2019-05-07 21:34:08
【问题描述】:
我是 Nifi 的新手,我必须使用来自 Kafka 的 JSON 主题 并想将其转换为 CSV 文件,我只需要选择几个标量和一些嵌套字段。
我需要做以下事情:
Consume topic - Done
Json to CSV
Include header in the CSV file
Merge into single file (if its split)
Give a proper filename with date
点击以下链接: https://community.hortonworks.com/articles/64069/converting-a-large-json-file-into-csv.html
但不确定这是否是正确的方法,也不知道如何制作单个文件。
我正在使用NiFi (1.8) and schema is stored in Confluent Schema Registry
Json 示例:
{
"type" : "record",
"name" : "Customer",
"namespace" : "namespace1"
"fields" : [ {
"name" : "header",
"type" : {
"type" : "record",
"name" : "CustomerDetails",
"namespace" : "namespace1"
"fields" : [ {
"name" : "Id",
"type" : "string"
}, {
"name" : "name",
"type" : "string"
}, {
"name" : "age",
"type" : [ "null", "int" ],
"default" : null
}, {
"name" : "comm",
"type" : [ "null", "int" ],
"default" : null
} ]
},
"doc" : ""
}, {
"name" : "data",
"type" : {
"type" : "record",
"name" : "CustomerData"
"fields" : [ {
"name" : "tags",
"type" : {
"type" : "map",
"values" : "string"
}
}, {
"name" : "data",
"type" : [ "null", "bytes" ]
"default" : null
} ]
},
"doc" : ""
} ]
}
请指导我。
【问题讨论】:
-
JSON 是什么样的,您打算如何将嵌套字段表示为 CSV 值?
-
我已经更新了示例 json。嵌套字段应作为 csv 文件中的单个记录进入。