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

Alteryx Designer Desktop Discussions

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

Creating a Macro to Return a File Based on Folder Path and File Name

hcho
8 - Asteroid

Hello Alteryx Community,

I'm trying to create a macro that takes a folder path and a file name as inputs and returns the specific file based on these keys.

For example:

  • Folder: "files"
  • Files under "files folder": fileA, fileB

When I input "fileA" along with the folder path, I want the macro to return the data from fileA. Below is the sample data for fileA:

Id Length Width Height Weight

box110203050
box210302040
box320151510

I've explored tools like the Directory and Dynamic Input, but I'm unsure how to configure them to achieve this functionality. I've also attached an example files folder for reference.

Any guidance or suggestions on how to approach this would be greatly appreciated!

Thank you in advance for your help!

6 REPLIES 6
binuacs
21 - Polaris

@hcho sample attached

image.png

hcho
8 - Asteroid

Thank you for sharing the sample workflow! I'm trying to follow along, but I'm still confused. It seems like the macro can take the folder path but not the file name directly. Does this mean the only way to specify a different file is by entering the macro and manually changing the file name? Or is there a way to dynamically select the file name as well?

I appreciate your help, @binuacs!

binuacs
21 - Polaris

@hcho Are you looking for an interface tool where the user can give the file name to the macro?

hcho
8 - Asteroid

No, I am looking for a file name fed into macro in a table formed like this so that this can call each file iteratively later on:

fileName

fileA
 
 
binuacs
21 - Polaris

@hcho I added a text input tool where you can add the file name, then the filter tool filter out the file path from the directory tool output and give you the output from the macro

image.png

apathetichell
19 - Altair

@hcho - when you say "return the data" if this is an excel file - you must supply the sheet. the process of mapping a folder to a filename is straight forward. the part where you say "and then choose this sheet" requires a rule structure. you must create that rule structure and explain it. 

Labels