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.

How to parse a record having multi-character delimiter in NiFi?

Highlighted

How to parse a record having multi-character delimiter in NiFi?

I have a scenario where the records are having multi-character delimiter as shown below,

1$$John Wright$$New Zealand

I need to fetch the value of the second field(John Wright).

Is there any function/processor to parse multi-character delimiter record?

Currently I am replacing the multi-character delimiter($$) with single delimiter($) using ReplaceText processor & parsing the value. Is there a better approach?

4 REPLIES 4

Re: How to parse a record having multi-character delimiter in NiFi?

I think ReplaceText processor is a good fit for this use case.

Highlighted

Re: How to parse a record having multi-character delimiter in NiFi?

Thanks Rajkumar!!!

Highlighted

Re: How to parse a record having multi-character delimiter in NiFi?

Contributor

@Rohit Ravishankar

I think the easiest option is probably going to be replaceText, and then use either ExtractText, or NiFi Expression Language.

After your replaceText (fixing delimiter) processor, you could use Nifi Expression Language (getDelimitedField) and specify your new delimiter to get the exact file you need, and also trim if needed like so:

If your record contains:

1$John Wright$New Zealand

${record:getDelimitedField(2, '$')}

This would return "John Wright". You could also do this to trim if needed as well:

${record:getDelimitedField(2, '$'):trim()}
Highlighted

Re: How to parse a record having multi-character delimiter in NiFi?

Thanks Devin!!! I also did the same.

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