Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Select Input .txt file based on creation date

mschmeiser
7 - Meteor

My ERP system creates a tab delimited .txt file on a daily basis that only includes the data processed in that particular cycle. I tried to use the input tool, however, you must select the exact file that you want to use. how do you get the workflow to use the most recent file in a particular folder regardless of when you run the workflow?

3 REPLIES 3
SeanAdams
17 - Castor
17 - Castor

Great question - if you use a directory tool; you can find all the files that have the filename pattern you're looking for - and then instead of using the classic input tool; use a dynamic input using this filename of the latest one.

 

Give this a try - we use this quite frequently - and if you get stuck I'll mock this up for you quickly.

 

Cheers

Sean

mschmeiser
7 - Meteor

I was able to use the directory tool to identify the most recent file placed in a folder and then input it using the dynamic input tool, however, it only works if I place my workflow in the same directory that the file is sitting in. Is that true? I need the ability to dynamically input several different files from different folders, but I cannot place my workflow tool in each of those folders. Is that possible?

Schmeiser, Marliese

Joe_Mako
12 - Quasar

Here is an example workflow

 

last file in folder.png


- Directory pointed tot he folder of interest
- Sort by LastWriteTime - Descending
- Sample First 1 record
- Dynamic Input using a representative file to set expectations, and configured to use FullPath (generated from the Directory tool) to change the entire file path (both the directory and file name).

 

Be aware that if the file that you used as a representative file to configure the expected connection in the Dynamic Input tool no longer exists in the future, you will see a red exclamation mark before running. It is safe to ignore that and run the workflow. If the error message persists after running, then there is an issue.

 

If you use "FileName" instead of "FullPath", you would limit your self to having the .yxmd in the same directory as your files as the "FileName" does not have the directory.

Labels
Top Solution Authors