Hi Prabhu,

The SimpleCsvFileLookupService is meant to look up one value and add
it back to the records.

So lets say you want to lookup the gender and add it to the original records...

You would configure SimpleCsvFileLookupService with the following:

- Lookup Key Column = ID
- Lookup Key Value = Sex

When the service starts it will then make a map of ID to Sex so you would have:

2201 -> Male
3300 -> Female

Now in LookupRecord you would add a user-defined property of "key" =
"ID" since ID is the column from the incoming records that would to
use as the key into the above map.

Then "Result Record Path" should be the field in the records where you
want the result of the look up go to, so you would want something like
"/Sex".

You'll also need to have a field called "Sex" in the schema being used
by the record writer. You could make one schema that has a nullable
Sex field and have the CsvReader and FreeFormTextWriter both reference
that schema, or you could let the CsvReader infer the schema from the
fields (it won't have a sex field) and then use a different schema for
the writer.

-Bryan


On Fri, Jul 7, 2017 at 6:28 AM, prabhu Mahendran
<[email protected]> wrote:
> I tried to join two csv file based on id with respect to the below
> reference.
>
>
> How to join two CSVs with Apache Nifi
>
>
> i'm using NiFi-1.3.0
>
>
> Now i have two csv files.
>
>
> 1.custom.csv
>
>
> No,Name,ID,Age
>
> 1,Hik,2201,33
>
> 2,Kio,3300,22
>
>
> 2.gender.csv
>
>
> ID,Name,Sex
>
> 2201,Hik,Male
>
> 3300,Kio,Female
>
> I try to combine those tables with "ID" like following endresult.
>
>
> No,Name,Sex,ID,Age
>
> 1,Hik,Male,2201,33
>
> 2,Kio,Female,3300,22
>
> I have using following processor structure.
>
>
> GetFile-SplitText-ExtractText-LookUpRecord-PutFile
>
> In that lookup record i have configured
>
>
> RecordReader = "CSVReader"
>
> RecordWriter="FreeFormTextRecordSetWriter"
>
> LookUpService="SimpleCSVFileLookUpService"
>
>
> ResultRecordPath-->/Key
>
> key-->/ID
>
> In that LookUpService i have given path of the "gender.csv" and setted
> LookUpKeyColumn and LookUpValueColumn to be "ID".
>
>
> In that FreeFormTextRecordSetWriter i have given text
> value"${No},${Name},${ID},${Age},${Sex}"
>
>
> It yields below result only.
>
>
> No,Name,Sex,ID,Age,
>
> 1,Hik,Male,2201,33,
>
> 2,Kio,Female,3300,22,
>
> It doesn't have "sex" column.
>
>
> I think i could not configured correctly.
>
>
> i don't know how to use ResultRecordPath & one dynamic attribute(Key)
> specification in LookUpRecord?
>
>
> Can anyone guide me to solve my issue?

Reply via email to