DumbNewbie
DumbNewbie

Reputation: 160

How to read from a CSV file

The problem:

I have a CSV file. I want to read from it, and use one of the values in it based on the content of my flow file. My flow file will be XML. I want to read the key using EvaluateXPath into an attribute, then use that key to read the corresponding value from the CSV file and put that into a flow file attribute.

I tried following this:

https://community.hortonworks.com/questions/174144/lookuprecord-and-simplecsvfilelookupservice-in-nif.html

but found requiring several controller services, including a CSV writer to be a big more than I would think is required to solve this.

Upvotes: 1

Views: 937

Answers (1)

mattyb
mattyb

Reputation: 12103

Since you're working with attributes (and only one lookup value), you can skip the record-based stuff and just use LookupAttribute with a SimpleCsvFileLookupService.

The record-based components are for doing multiple lookups per record and/or lookups for each record in a FlowFile. In your case it looks like you have one "record" and you really just want to look up an attribute from another attribute for the entire FlowFile, so the above solution should be more straightforward and easier to configure.

Upvotes: 1

Related Questions