3

i have a stream of JSON records that i convert it into CSV record successfully with this instruction. but now i want to merge this CSV records into one CSV file. below is that flow:

nifi flow

at step 5 i face with around 9K csv record, how do i merge it into one csv file using MergeRecord processor?

my csv header:

field1,field2,field3,field4,field5,field6,field7,field8,field9,field10,field11

some of this fields may be null and vary in records.

6
  • 1
    Is that a requirement to merge it to exactly one file? That won't be a good approach, IMO. If not, please go through nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/…. Minimum Number of Records and Maximum Number of Records are the ones that ultimately decide how the merge happens. Commented May 30, 2018 at 11:03
  • @sivaprasanna-sethuraman not exactly one file, one file that follows from merge strategy (like: bin packing algorithm) Commented May 30, 2018 at 12:21
  • Please try it out and tell if something doesn't work as expected. Commented May 30, 2018 at 12:24
  • @sivaprasanna-sethuraman clearly i try this processor; record reader: csvreader and writer: CSVRecordSetWriter; then with default properties and same schema that i used in json2csv convert i face with this error: "Cannot write Schema Name As Attribute because the Schema Name is not known merge csv" Commented May 30, 2018 at 12:25
  • 3
    Configure CsvRecordSetWriter controller service and Schema Write Strategy to Do not write schema Commented May 30, 2018 at 12:26

2 Answers 2

0

after this use UpdateAttribute configure it so that it can save the file with a filename and after that use putFile to store it to a specific location

Sign up to request clarification or add additional context in comments.

Comments

0

I had a similar problem and solved it by using RouteonAttribute processor. Hope this helps someone.

Created a routing till the ${merge.count} reaches 1

Below is how I configure the processor using ${merge.count:equals(1)}

${merge.count:equals(1)} ensures all the input flowfiles in the batch are merged into one flowfile and passed downstream

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.