In Apache NiFi, flowfiles are the fundamental data structures that carry data through the system. While flowfiles have content, they also have attribute (metadata that describes the content). Sometimes, it’s useful to convert specific pieces of content into attributes for easier processing and routing. This article will guide you through this process.
Step-by-step process :
Generate CSV Data
Convert CSV to JSON
Split Data
Extract Content (JSON) to Attributes
Set Up The Flow in NiFi
NiFi Flow Explanation:
Generate order details
We begin by generating order details using the GenerateFlowFile processor, which creates flowfiles based on our sample data.
Convert CSV to JSON
The next step is converting the data in the flowfile from CSV format to JSON format.
Split data
We then split the JSON array into individual flowfiles, creating one flowfile for each entry.
Extract content (JSON) to attributes
Finally, we extract the customer_id and order_id values into attributes for each flowfile.
Sample Data
Input Data: Order Details
Convert Data: CSV to JSON
Output Data: 4 Flowfiles
Processor Properties
Generate order details
Convert CSV to JSON
Split Data
Extract Content (JSON) to Attributes
Step-by-Step Video Guide
Converting Content to Attributes in Apache NiFi
Comments