首页 文章

如何在apache NIFI中将文本文件转换为avro

提问于
浏览
-2

我们试图在Nifi中使用ConvertCSVToAvro将文本文件(逗号分隔)转换为avro,但输出是ConvertCSVToAvro处理器的文本文件 .

1 回答

  • 0

    您好@Teekoji Rao BeLkAr,

    把csv转换成avro,

    • 您需要使用SplitText Processor逐行拆分文本 .

    • 使用正则表达式通过使用ExtractText处理器提取值,它将结果值作为每个流文件的属性 .

    • ReplaceText处理器将属性替换为流文件的内容 .

    • InferAvroSchema处理器获取流文件内容的模式 .

    • ConvertCSVToAvro处理器将流文件内容转换为Avro格式 Note:- 我在ReplaceText处理器中使用管道(|)作为分隔符替换值,您可以根据需要使用任何分隔符 . 但是分隔符需要与InferAvroSchema csv头定义匹配

    All the configurations for the processors are mentioned in the link,

    [https://community.hortonworks.com/questions/131332/nifi-convert-text-file-consisting-of-key-value-pai.html?childToView=131440#answer-131440][1]](https://community.hortonworks.com/questions/131332/nifi-convert-text-file-consisting-of-key-value-pai.html?childToView=131440#answer-131440][1])

相关问题