Skip to main content
nishank_paras
Silver ⭐️⭐️⭐️
February 3, 2020
Solved

drop a column from csv

how can i drop column from csv 

i only want to keep one selected feild

 

MattWho
MattWhoAnswer
Titanium ⭐️⭐️⭐️
February 7, 2020

@nishank_paras 

 

Let's assume your input FlowFile content looks like this:

Date, IP, Description
01-30-2020, 10.0.0.1, server1
01-30-2020, 10.0.1.2, server2
01-30-2020, 10.0.3.4, server3
01-30-2020, 10.0.4.6, server4
01-30-2020, 10.0.10.2, server5

 

You would configure your ReplaceText processor as follows:
Screen Shot 2020-02-07 at 11.19.05 AM.png

The Search Value contains a java regular expression which will match on your entire line and uses one capture group.   The Replacement Value says to replace everything matched by the Search Value Regex with only the value from capture group 1.  We then configure ReplaceText to evaluate that Regex against each line.

The resulting FlowFile output to the success relationship will have content that looks like this:

IP
10.0.0.1
10.0.1.2
10.0.3.4
10.0.4.6
10.0.10.2


Hope this helps,

Matt

8 replies

cjervis
Community Manager
Community Manager
February 3, 2020

@nishank_paras Can you provide some additional details for those who may be able to assist you. Specifically, what components (Spark, NiFi, etc.) are you trying to do this with?

 

 

Translate
Keep the questions coming
nishank_paras
Silver ⭐️⭐️⭐️
February 3, 2020

i am new to this 

i have a csv file with three column name, IP, description 

i want to keep ip only and drop other

guide me to the best possible way

listfile ---> fetch file ----> ?? ----->putfile

also tell me the configuration settings if any

 

Technology - nifi

Translate