Convert a CSV file to JSON using Apache NiFi

青春壹個敷衍的年華 提交于 2019-12-01 13:49:25

There are a few different ways this could be done...

  • A custom Java processor that reads in a CSV and converts to JSON
  • Using the ExecuteScript processor to do something similar in a Groovy/Jython script
  • Use SplitText to split your original CSV into single lines, then use your current approach with ExtractText and ReplaceText, and then a MergeContent to merge back together
  • Use ConvertCsvToAvro and then ConvertAvroToJson

Although the last option makes an extra conversion to Avro, it might be the easiest solution requiring almost no work.

This question is a bit older, but there is now a ConvertRecord processor in NiFi 1.3 and newer, which should be able to handle this conversion directly for you, and it avoids having to use split up the data by creating a single JSON array with all of the values, if that is desirable.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!