
PutFile writes the contents of the flowfile to a local directory UpdateAttribute adds the file name with the JSON extension as an attribute to the flowfileĥ. Using a JsonRecordSetWriter controller service that references the same AvroSchemaRegistry schemaĤ.The AvroSchemaRegistry contains a "users" schema which defines information about each record (field names, field ids, field types).Using a CSVReader controller service that references a schema in an AvroSchemaRegistry controller service.ConvertRecord converts the flowfile contents from CSV to JSON by: UpdateAttribute adds Schema Name "users" as an attribute to the flowfileģ. GetFile ingests a CSV file of user data from a local directoryĢ. Update Directory Path in PutFile ProcessorĬhange the Directory path in the PutFile processor to point to your local output directory: Update Directory Path in GetFile ProcessorĬhange the Input Directory path in the GetFile processor to point to your local input directory: All the controller services should be enabled at this point: Select the lightning bolt icons for both of these services. This will then allow you to enable the CSVReader and JSONRecordSetWriter controller services. Select the Controller Services tab:Įnable AvroSchemaRegistry by selecting the lightning bolt icon/button. This opens the NiFi Flow Configuration window. Select the gear icon from the Operate Palette: You should see the following flow on your NiFi canvas:

Import the provided template and add it to the canvas. Place the "users.csv" file in the input directory. One input directory and one for the JSON output. Demo Configuration Input and OutputĬreate two local directories. This useful site provides a free API to pull down randomly generated user data. Note: The CSV data originated from the site, RandomUser. Here is a template of the flow discussed in this tutorial: This tutorial was tested using the following environment and components: As such, the tutorial needs to be done running Version 1.2.0 or later.


Note: The record-oriented processors and controller services were introduced in NiFi 1.2.0. Additionally, the flow is modified to also convert the CSV file to Avro and XML formats. This tutorial walks you through a NiFI flow that utilizes theĬonvertRecord processor and Record Reader/Writer controller services to easily convert a CVS file into JSON format.
