How to list file names from an FTP in another file?

Hello snapLogic Community!
I am very new to the solution, but loving it more each day :slight_smile:

I am trying to read the name of files from an FTP directory and write the details to a separate file within the pipeline project folder.

I checked this post’s response, but this is listing assets in the SnapLogic environment, and I am looking to list the name of all files in an FTP location and print out the name of the files to a csv file or json.

Does anyone have any suggestions on how I can accomplish this?
Thank you in advance!

@izzy.babcock

Using Directory Browser you can list all the files from the given file location.

Regards,
Spiro Taleski

2 Likes

Thank you for your reply @Spiro_Taleski.
I had read over the documentation, but I am not sure how to actually get it to list the file names into another file. Which snaps should I use in this case?

@izzy.babcock

Once you get all the files from the ftp location using the Directory Browser Snap, you can use a Mapper Snap in order to map necessary fields produced by the Directory Browser Snap.

My question is: Do you want only to print/store the file names from ftp in one file in SnapLogic? Or do you want for each file on ftp to create separate file in SnapLogic project folder?

Based on the type of the file(csv, json, xml, excel), that you want to store the details, there are designated Snaps for each like: JSON Formatter, CSV Formatter etc.

Regards,
Spiro Taleski

Hi @Spiro_Taleski,

For now, it would suffice to have an excel file where each row will contain the name of the file.
How do I reference the file name in the mapper? Is there a document listing all $fields that can be referenced on a particular snap?

Best,
Izzy Babcock

@izzy.babcock

I am attaching sample pipeline that may helps you:

CommunityTask_2021_10_07.slp (6.0 KB)

Regards,
Spiro Taleski

1 Like

Hi @Spiro_Taleski,

Thank you for sharing this sample pipeline with me.

When I run it (after updating it so it reflects my files), the result is an .xlsx with binary content, but I thought that the file writer would read binary and write it as document to the endpoint. Am I missing something?

image

Also, how do you know that $Name references the name of the file in a directory? How do I know what can be referenced as a variable/field for a specific snap?

image

Thanks in advance.

Best,
Izzy Babcock

@izzy.babcock

Once you run the pipeline, the file is stored in the same project space where the pipeline is located. You can download the file, and the data will be in human-readable format.

The Directory Browser Snap on the output in the $Name it references the Name of the file on that location.

Regards,
ST

2 Likes

Thanks @Spiro_Taleski, after looking at the output generated by the snap, I was able to identify the column names being generated by the tool, which are the ones I can refer to with $.