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.

Split FlowFile into multiple files based on category with Nifi

Solved Go to solution
Highlighted

Split FlowFile into multiple files based on category with Nifi

New Contributor

Hello, guys,

I'm trying to use Nifi to split a text file into 2 other files. I just have a problem with that: I need to split them based on their category type.

e.g.
FlowFile content:
Some fixed text |1| more text
Another field |8| more text
Last one |1| more text

With that, I'd like to split this file into, for example:
first FlowFile:

Some fixed text |1| more text
Last one |1| more text

second FlowFile:

Another field |8| more text

Do you guys have any idea on how to accomplish that using Nifi? I appreciate any help you can provide.

Thanks in advance,

Cheers!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Split FlowFile into multiple files based on category with Nifi

Super Guru

@Cesar Rodrigues

Use RouteText Processor (The data is then routed according to these rules, routing each line of the text individually) and then configure the processor as

Route text Configs:-

Routing Strategy

Route to each matching Property Name

Matching Strategy

Contains

Ignore Leading/Trailing Whitespace

true

Ignore Case

true

Grouping Regular Expression No value set flowfile1

|1| more text //checks the line having the content and routes to flowfile1 relation

flowfile2

|8| more text //checks the line having the content and routes to flowfile1 relation

56569-routetext.png

Input:-

Some fixed text |1| more text
Another field |8| more text
Last one |1| more text

Output:-

Flowfile1:-

as we are checking if the contents having |1| more text so the following lines will routes to flowfile1 relationship

Some fixed text |1| more text
Last one |1| more text

Flowfile2:-

lines having |8| more text will route to this relation

Another field |8| more text

Flow:-

56570-flow.png

2 REPLIES 2

Re: Split FlowFile into multiple files based on category with Nifi

Super Guru

@Cesar Rodrigues

Use RouteText Processor (The data is then routed according to these rules, routing each line of the text individually) and then configure the processor as

Route text Configs:-

Routing Strategy

Route to each matching Property Name

Matching Strategy

Contains

Ignore Leading/Trailing Whitespace

true

Ignore Case

true

Grouping Regular Expression No value set flowfile1

|1| more text //checks the line having the content and routes to flowfile1 relation

flowfile2

|8| more text //checks the line having the content and routes to flowfile1 relation

56569-routetext.png

Input:-

Some fixed text |1| more text
Another field |8| more text
Last one |1| more text

Output:-

Flowfile1:-

as we are checking if the contents having |1| more text so the following lines will routes to flowfile1 relationship

Some fixed text |1| more text
Last one |1| more text

Flowfile2:-

lines having |8| more text will route to this relation

Another field |8| more text

Flow:-

56570-flow.png

Re: Split FlowFile into multiple files based on category with Nifi

New Contributor

@Shu, thank you very much. It worked perfectly!

Don't have an account?
Coming from Hortonworks? Activate your account here