Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Extract the CSV fields from each record and add them as attributes to Corresponding Flow File.

Extract the CSV fields from each record and add them as attributes to Corresponding Flow File.

New Contributor

Hi,

I have Zip file with some txt files and index file(csv) inside. How to add the fields in the each CSV record as attribute to Txt files matching its filename?

List of Files:

  1. a.txt
  2. b.txt
  3. c.txt


CSV:

filename, Date, Origin, Owner

a.txt, 20190103, AT, WU

b.txt, 20190103, CT, WU

c.txt, 20190103, OT, XO

2 REPLIES 2

Re: Extract the CSV fields from each record and add them as attributes to Corresponding Flow File.

New Contributor

Once you use UnpackContent to unzip the file, each flowfile will be one CSV. You should then be able to use ExtractText to pick out the fields from the CSV that you want to turn into attributes. Use a regex to tell ExtractText where to find the value for each attribute.

Re: Extract the CSV fields from each record and add them as attributes to Corresponding Flow File.

New Contributor

Hi @Ryan Shirley

Thank you for your response. But the zip file have some .txt files along with one .csv file. I want to add the csv field values as new attributes to .txt files if its filename matches.

let's say i have one text file 'a.txt' and from the csv file i extract the values of fields like 'origin', 'owner'. How to add these values as attributes to 'a.txt' file?