apache-nifi - How to convert CSV to JSON using Apache Nifi?
问题描述
How to convert CSV to JSON using Apache Nifi?
I have a CSV file and I need to covert to json. How to draw a normal flow diagram. Please tell me the properties and figure details.
My understanding is 4 block has to there. 1.GenerateFLow 2.ConverttoAvro 3.Converttojson 4.Savethefile. I am new to the Nifi and I have installed nifi, struggling to configure
"model","speed","mileage"
"audi",4,2
"benz",4,10
"bmw",7,4
"jaguar",7,22
My Json
[
{
"model": "audi",
"speed": 4,
"mileage": 2
},
{
"model": "benz",
"speed": 4,
"mileage": 10
},
{
"model": "bmw",
"speed": 7,
"mileage": 4
},
{
"model": "jaguar",
"speed": 7,
"mileage": 22
}
]
I went through Convert a CSV file to JSON using Apache NiFi
解决方案
您所描述的方法是.old
(needs to follow if you are using prior to NiFi-1.2 version)
从NiFi-1.2开始引入record oriented processors
。
对于您的情况,使用
ConvertRecord
处理器并配置/启用记录读取器(CSVReader)/写入器(JsonSetWriter)控制器服务。然后 NiFi ConvertRecord处理器读取传入的
CSV
数据并以JSON
格式写入输出流文件。
请参阅此convertCsvtoJson
链接描述如何使用 ConvertRecord 处理器的分步过程。
Starting from NiFi-1.2 Version
流动:
1.GenerateFlowFile
2.ConvertRecord
3.SaveFile (Using PutFile/PutHDFS)
Prior to NiFi-1.2 Version
流动:
1.GenerateFlowFile
2.InferAvroSchema
3.ConvertCSVToAvro
4.ConvertAvroToJSON
推荐阅读
- java - Java 停止声音按钮无法正常工作
- r - 快速调整 r 平方提取
- python - 在 dockerfile 中使用 python secrets 模块是否安全?
- firebase - Firebase 托管,如何一次在多个帐户上部署相同的代码
- configuration - Mercurial 中特定于存储库的特殊/点文件
- python - 每个 id 创建 n 行 | 熊猫
- python-3.x - 我想使用 Matplotlib 小部件进行下拉
- python - 范围内素数的“生成器”
- git - Git 从第三个分支合并
- django - 使 DRF POST 操作像 Django Admin 创建对象一样工作