Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Reading Multiple excel Files (Only select few sheets from each file) from a folder

yatish1164
7 - Meteor

Dear Community,

 

I have this folder where multiple files are placed by a department each month. These files will be replaced with the latest files each month when they come in so I would essentially be using Alteryx to create something like a table for me that can be then written into a database. 

 

The challenges I have are:

1. Each file will be overwritten so I cannot use a specific template for a dynamic input tool

2 Each excel file will have different number of sheets. I just need to pick 4 sheets these files

 

I have tried the below approach but I am not sure if there is a better way to do this.

Altexyx Input.PNG

List of sheet Names in Files:

File A: FC Summary, Road, Air, Ship, abc, def

File B: FC Summary, Road, Air, Ship, 123, pqd, jec

File C: FC Summary, Road, Air, Ship, 789, 564, led

 

I am only interested in bringing in FC Summary, Road, Air, Ship and I have made sure that their field names match so that I can then do a union.

 

End result: FC summary of all the different files will be unionid and written to a table in the Database

Road from all the different files will also be unionid together and go into a table

and same happens for Air and Ship.

 

Any help is highly appreciated! 

6 REPLIES 6
mceleavey
17 - Castor
17 - Castor

Hi @yatish1164 ,

 

I've attached an example workflow along with the required tools to do exactly this.

Simply point the directory tool to the folder you want, and the naming scheme you want.

 

Hope this helps,

 

M.



Bulien

patrick_mcauliffe
14 - Magnetar
14 - Magnetar

@yatish1164  it looks like you need batch macros.  You're on the right track getting the list of names first.  Now, you just need to have those run like independent inputs... which is why we use a batch macro.

 

Here's how:

Set up a regular input like you would for any one of the Excel sheets.

I also like to output the file name so I know where it came from (option 5 on Data Input)

 

patrick_mcauliffe_0-1634037065738.png

 

In the Interface tools, grab a Control Parameter and add that to the canvas.

Connect the Control Param to the Data Input and it will automatically add the Update tool.

 

patrick_mcauliffe_1-1634037144190.png

 

 

Select the full file path, including the sheet within the Update tool.

 

 

patrick_mcauliffe_2-1634037215449.png

 

 

Now, if you want to output to the database at this point, you can.  Or, you can pull the data back into the workflow.

Assuming you'd still want to do some work on this data, add a Macro Output.  Then press  Ctrl + Alt + D.  This will bring up the Designer Interface.

patrick_mcauliffe_3-1634037361997.png

 

To avoid errors from mismatched schemas, on the Designer Interface, left side, tap the gear icon.

 

We want the macro to be set to anticipate the changing schema, so as to wait and union the data by name (of whatever other configuration you need).

 

patrick_mcauliffe_4-1634037428295.png

 

Before saving the macro, I generally rename the Control Parameter Input something less generic

 

patrick_mcauliffe_5-1634037503982.png

 

 

 

Now, save the Macro and go back to the canvas where you were outputting the list of sheet names.

Add a formula so that you have a field named for the Control Param input (like I have above with "Full Path") and it includes the full path of the file.

 

 

I usually do this by setting option number 5 to Full Path, like this:

 

patrick_mcauliffe_6-1634037693470.png

 

 

 

So, very simply, to get the full path with sheet name, my formula only needs to replace the "list of sheet names" reference.

patrick_mcauliffe_7-1634037800879.png

 

 

 

And that's what you feed into the new macro.

 

 

yatish1164
7 - Meteor

Thank you @patrick_mcauliffe and @mceleavey. Made my first batch macro today! I feel like an expert already 😄

mceleavey
17 - Castor
17 - Castor

noice.gif



Bulien

atcodedog05
22 - Nova
22 - Nova

Great in-depth explanation @patrick_mcauliffe 🙂 👍

 

Congrats @yatish1164 on building your first batch Macro 😀 🎉🎉

 

And nice to see you after a long time @mceleavey 😎

mceleavey
17 - Castor
17 - Castor

Busy times, @atcodedog05 .

Hopefully see you at the next user group on November 5th 🙂



Bulien

Labels