Alteryx Designer Desktop Discussions

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

Output filename and get latest file in month

Bralex
5 - Atom

Is there a way to use the directory tool and output the filename as a field? 

 

I have daily files in one folder going back with filename e,g "alteryx-20200813" and I want the datefield to be a column. 

The object is to append all the end of month files to one file.

 

I have read many posts in the forum and the best solution I have found is to use the input tool and the *, but the files are quite huge and many so the runtime will be quite bad. 

Anyone know a better solution?

 

 

 

7 REPLIES 7
wwatson
12 - Quasar

I created the following list of files:

wwatson_0-1597310236788.png

Then used the enclosed workflow to pull the last July file and the last August files in.

wwatson_2-1597310363554.png

 

 

 

wwatson_1-1597310308270.png

 

Hopefully this solution will work for you.

 

DavidP
17 - Castor
17 - Castor

Hi @Bralex 

 

Below is a sample workflow that reads the list of files in a folder with a directory tool. It assumes the filenames are alteryx-20200731.csv; alteryx-20200730.csv; alteryx-20200729.csv; etc.

 

It then extracts the date and breaks it up into year, month, day. Now you can sort by Year, Month, Day (changing the sort order for day to descending) and then use the Sample tool where you Group by Year and Month and select the 1st record.

 

This gives you the file for the last day of every month.

 

If you run my workflow, you'll get an error since you won't have the folder I'm referring to, so I added the output of my Directory tool in a Text Input tool, so that you can see how it works.

 

 

Untitled.png

Bralex
5 - Atom

Thank you for your replies, much appreciated.

 

What I am really looking for is to get the filename to a field, or as a column.

So after selecting the relevant files, as your solutions above is perfect for, then output the filename as a column in the dataset.

 

 

DavidP
17 - Castor
17 - Castor

With the solution that @wwatson proposed, where the list of files are loaded into one dataset with the dynamic input tool, you can select the option in the template file setup in the dynaimc input tool to output the file name as a field.

 

You can either select filename or fullpath.

 

DavidP_0-1597313256930.png

 

wwatson
12 - Quasar

what about a batch macro?

 

wwatson_0-1597314050184.pngwwatson_1-1597314108734.png

 

wwatson
12 - Quasar

or just do what @DavidP  suggested:

wwatson_0-1597315147184.png

 

Bralex
5 - Atom

Thank you both so much, really appreciate it. 

Labels