Support Questions

Find answers, ask questions, and share your expertise

Split FlowFile into multiple files based on category with Nifi

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

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

View solution in original post

2 REPLIES 2

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

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

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.