Danish M
Danish M

Reputation: 105

Apache nifi ListSFTP fetch files form a SFTP location that have todays date in the name

I want to read a file dynamically from a SFTP location on day to day basis, based on the date in the file name for example. I'm using ListSFTP's file filter regex to match only those files with todays date,

For example, today's file is data_04142021.csv, and tomorrow it would be data_04152021.csv

Which file filter regex can I use to do that?

I've been trying ^data_[${now():format('MMddyyyy')}].* but with no success.

Any help would be appreciated.

Upvotes: 1

Views: 1433

Answers (1)

yaprak
yaprak

Reputation: 547

You should use ListSFTP and FetchSFTP together. First of all, list files in directory and use RouteOnAttribute to filter out today's file and lastly, get content of the file. I am using ListFile and FetchFile in my example but approach is the same.

enter image description here

you can add a route on RouteOnAttribute like this

 ${filename:contains(${now():format('MMddyyyy')})}

enter image description here

Upvotes: 1

Related Questions