Support Questions

Find answers, ask questions, and share your expertise

NIFI processor for converting a numeric type to string type for a specific column in CSV file

avatar

Hi,

I am new to NIFI, and I was wondering if I could change the specific column in the csv file.

for example, if the column has numerical values it is supposed to be converted to string type 

like if the column had a numerical value 1 it should be converted to apple in the same column

I tried doing it by referring to websites but still I was not successful. Looking forward for some response for this problem. Thanks in advance

Karankk_0-1723652411864.png

 

 

Karankk_2-1723652522279.png

 

1 ACCEPTED SOLUTION

avatar
Contributor

@Former Member 

LookupRecord processor can be used in this case.   Please check if this method works for you.

Sample CSV input

id,brand,phone
10,Samsung,1
20,Apple,2


Expected output (codes 1 and 2 are replaced with names)

id,brand,phone
10,Samsung,Note
20,Apple,iPhone

I tried nifi flow as below

shiva239_0-1723667109978.png

Lookup record configuration

shiva239_1-1723667210044.png

CSV Reader

shiva239_2-1723667287101.png

CSV Recordset Writer

Didnt make any change.  Used default settings

 

Simple KeyValue Lookup service.  There are several lookup services available in Nifi.  You may use right service as per your requirement.

shiva239_3-1723667414993.png

 

 

 

 

 

 

View solution in original post

2 REPLIES 2

avatar
Community Manager

@Former Member Welcome to the Cloudera Community!

To help you get the best possible solution, I have tagged our NiFi experts @MattWho @mburgess  who may be able to assist you further.

Please keep us updated on your post, and we hope you find a satisfactory solution to your query.


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
Contributor

@Former Member 

LookupRecord processor can be used in this case.   Please check if this method works for you.

Sample CSV input

id,brand,phone
10,Samsung,1
20,Apple,2


Expected output (codes 1 and 2 are replaced with names)

id,brand,phone
10,Samsung,Note
20,Apple,iPhone

I tried nifi flow as below

shiva239_0-1723667109978.png

Lookup record configuration

shiva239_1-1723667210044.png

CSV Reader

shiva239_2-1723667287101.png

CSV Recordset Writer

Didnt make any change.  Used default settings

 

Simple KeyValue Lookup service.  There are several lookup services available in Nifi.  You may use right service as per your requirement.

shiva239_3-1723667414993.png