nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Payne <>
Subject Re: How to count the number of occurrences of a certain string in file
Date Tue, 07 Nov 2017 13:33:22 GMT

I don't believe there are any processors right now that will count the number of occurrences
of some string in a FlowFile. I would recommend either using an ExecuteScript processor and
scripting it out in Groovy/Jython, or if you're comfortable enough with Java and want to get
hands a bit dirtier, you could actually update the ScanContent processor to optionally count
the number of occurrences of each term in the dictionary, rather than simply routing to 'matched'
or 'unmatched'. Then we could have ScanContent provide attributes such as <Search Term>
= <Occurrences>.


> On Nov 6, 2017, at 3:58 PM, tzhu <> wrote:
> Hi,
> I have a text log file. I want to count the number of occurrences of strings
> in the file and store it in a SQL table. For example, I want to count the
> number of times the string "Established connection to server" present in the
> file as TOTAL_CONNECTIONS and the number of times "Lost connection to
> server" existed in the same file as TOTAL_DISCONNECTION.
> I don't know how I should count the strings in this case. I find this blog
> as a template:
> <>   Maybe I can
> modify things from this?
> Any suggestions would be appreciated.
> Thanks,
> Tina
> --
> Sent from:

View raw message