Expand my Community achievements bar.

List all files, but only load 1

Avatar

Level 6

Another team is leaving any of these 3 files in our SFTP: a) DTI_AAA.csv.gz, b) DTI_BBB.csv.gz, c) DTI_CCC.csv.gz. 

However, there are other files in there already, so I need to list all files and only load "a", "b" or "c".  They will not coexist at the same time in the SFTP, once loaded in it's data inserted/updated in their schema, the file should be deleted.

File Transfer activity docsshow the option "list files", and all files would be stored in "vars.filenames".

The List all files option, available when selecting the File listing action, allows you to store all files present on the server in the event variable vars.filenames wherein the file names are separated by \n characters.

I'm currently getting: 
09/10/2024 9:04:46 PM Error in the SSH layer
09/10/2024 9:04:46 PM CRL-290002 Download error in cURL
09/10/2024 9:04:45 PM Error in the SSH layer

And also vars.filenames is undefined. - logInfo("vars.filenames = " + vars.filenames)

ogonzalesdiaz_0-1726020421437.png

 

ogonzalesdiaz_1-1726020586770.png



How do I access those file names and use regular expressions to match only any of these: a) DTI_AAA.csv.gz, b) DTI_BBB.csv.gz, c) DTI_CCC.csv.gz. ?

Regex could be something like: DTI_.*\\.csv\\.gz

2 Replies

Avatar

Community Advisor

Hello @ogonzalesdia  Move logInfo logic to next activity. If you are adding this logic to file transfer activity then it will not print anything because that code will be executing before pulling the file metadata from SFTP.


     Manoj
     Find me on LinkedIn

Avatar

Level 6

Hi Manoj, I've. But for this: logInfo("files: " + instance.vars.filenames);

I get:

09/12/2024 5:10:14 PM files: undefined
09/12/2024 5:10:14 PM files: undefined
09/12/2024 5:10:14 PM files: undefined
09/12/2024 5:10:14 PM files: undefined
09/12/2024 5:10:13 PM files: undefined
09/12/2024 5:10:13 PM files: undefined
09/12/2024 5:10:13 PM files: undefined
09/12/2024 5:10:13 PM files: undefined

ogonzalesdiaz_0-1726179602921.png

Maybe I have to loop over this variable vars.filenames? 

  1. Listing of files

    To list the files, select the File listing option from the Action field. Configuration of the remote server is the same as for receiving files. For more information, refer to this section.

    The List all files option, available when selecting the File listing action, allows you to store all files present on the server in the event variable vars.filenames wherein the file names are separated by \n characters.