01-08-2018 12:16 PM
Hi All,
I am trying to connect SFTP server and fetch multiple files from the source remote directory. File Reader snap has an option to get SFTP account but doesn’t find how to provide remote directory path.
In the remote directory, we are getting different types of files like *.txt where I need to apply filters based on the filenames to differentiate and invoke the different process to load into SQL DB.
Once I fetch the files from remote location how to delete the files.
Appreciate your inputs and any relevant links to look into more details. Let me know if you need any further details.
Thanks in advance,
Amar
01-08-2018 12:27 PM
Hi Amar,
I believe that the first challenge could be solved by using the FilePoller, and use the file filter option. This Snap will produce output containing the paths of the *.txt files, but not the actual files. After that, you could potentially use a ForEach Snap to process the path to the *.txt file. I need to confer with my teammates to see how one would go about deleting the files.
Hope this gets you off to a good start!
Thanks,
-Charlie
01-08-2018 02:21 PM
Thank you, Charlie for the quick response. I’ve tried FilePoller and fetch four files from the remote SFTP directory. FilePoller output showing four different paths for each individual file.
As a second snap, I have tried ForEach Snap but could not able to process the path. I might be giving wrong parameters. Attached ForEach Snap. Could you please guide how to process each individual file further.
Thanks again
Amar
01-08-2018 07:24 PM
Hi Amar,
Sorry for the delay. I was thinking more about your scenario, and I think I have a better suggestion. Since you may not need to “poll” for the files, I am thinking a different Snap would be better.
Say I want to boil the problem down to grabbing the files, and then deleting them…You could use a MultiFileReader Snap, with a file filter to get the desired types of file. The output will be a binary data stream.
You could connect this to a BinaryToDocument Snap and then perform operations on that document. At some point you would need to use a Mapper to key on the filename and pass that to a FileDelete Snap.
For the simpler case of just say…reading files and deleting them for proof of concept, you could use a DirectoryBrowser instead of the MultiFileReader. The DirectoryBrowser would return you attributes about all of the files that match the type filter (essentially a List in document format versus binary). Then you’d plug this into a Mapper Snap, to map the filename. Then you’d plug this into a Delete Snap where you configure it to read the file name from the mapped variable.
I hope this helps you get further towards your goal!
Thanks,
-Charlie
01-09-2018 04:16 PM
Hi Charlie,
Thank you, for the giving other options. I am still struggling to process the files from the first snap.
I am providing my findings for your reference. Appreciate your inputs further.
Multi File Reader( Multi File Reader )
Reads binary data from an endpoint (e.g. file, sldb, s3, sftp, ftp, adl, etc).
I’ve tried DirectoryBrowser and able to fetch files from the SFTP server and used mapper snap to take filename into the variable. If I use file delete snap again it is throwing same error as multi-file reader snap exception. The file parameter is not taking SFTP path with variable filename.
Appreciate your further support and also let me know how to extract data from the original file. The attributes from the directory browser snap showing bytes and name only.
Thanks in advance,
Amar