We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Reading multiple excel files and respective sheets within subdirectories

Dilver_Shaik
7 - Meteor

Hi Team,

 

I have a requirement like I need to read multiple excel files (similar names with different dates) which may present in sub-directories as well. I should be doing a pattern matching to get all the files. 

 

Example :

 

DIR_1\Business_Info_Jun10.xlsx

DIR_1\DIR_2\Business_Info_Jun05.xlsx

DIR_1\DIR_3\Business_Info_Jun10.xlsx

DIR_1\DIR_2\DIR_4\Business_Info_Jun11.xlsx

 

After reading all the necessary files, I need to fetch all the data in the respective files along with the sheet names.

 

Example :

 

DIR_1\Business_Info_Jun10.xlsx -> Contains sheets like (Tickets, Cases, Portfolio)

DIR_1\DIR_2\Business_Info_Jun05.xlsx -> Contains sheets like (Tickets, Cases, Portfolio)

DIR_1\DIR_3\Business_Info_Jun10.xlsx -> Contains sheets like (Tickets, Cases, Portfolio)

DIR_1\DIR_2\DIR_4\Business_Info_Jun11.xlsx -> Contains sheets like (Tickets, Cases, Portfolio)

 

In each sheet, I have few records

 

Example : 

DIR_1\Business_Info_Jun10.xlsx -> Contains sheets like (Tickets, Cases, Portfolio)

 

Tickets

Column-AColumn-BColumn-C
1234Test-1Test-2
4567 Test-3 Test-4

          

Cases

Column-AColumn-BColumn-C
1234Test-1Test-2
4567 Test-3 Test-4

 

Portfolio

Column-AColumn-BColumn-C
1234Test-1Test-2
4567 Test-3 Test-4

 

Similar sheets will be there in other files as well.

 

Expected Output :

 

FullpathFileNameSheetNameColumn-AColumn-BColumn-C
DIR_1\Business_Info_Jun10.xlsxBusiness_Info_Jun10.xlsxTickets1234Test-1Test-2
DIR_1\Business_Info_Jun10.xlsxBusiness_Info_Jun10.xlsxTickets4567 Test-3 Test-4
DIR_1\Business_Info_Jun10.xlsxBusiness_Info_Jun10.xlsxCases1234Test-1Test-2
DIR_1\Business_Info_Jun10.xlsxBusiness_Info_Jun10.xlsxCases4567 Test-3 Test-4
DIR_1\Business_Info_Jun10.xlsxBusiness_Info_Jun10.xlsxPortfolio1234Test-1Test-2
DIR_1\Business_Info_Jun10.xlsxBusiness_Info_Jun10.xlsxPortfolio4567 Test-3 Test-4
DIR_1\DIR_2\Business_Info_Jun05.xlsx Business_Info_Jun05.xlsx Tickets1234Test-1Test-2
DIR_1\DIR_2\Business_Info_Jun05.xlsx Business_Info_Jun05.xlsx Tickets4567 Test-3 Test-4
DIR_1\DIR_2\Business_Info_Jun05.xlsx Business_Info_Jun05.xlsx Cases1234Test-1Test-2
DIR_1\DIR_2\Business_Info_Jun05.xlsx Business_Info_Jun05.xlsx Cases4567 Test-3 Test-4
DIR_1\DIR_2\Business_Info_Jun05.xlsx Business_Info_Jun05.xlsx Portfolio1234Test-1Test-2
DIR_1\DIR_2\Business_Info_Jun05.xlsx Business_Info_Jun05.xlsx Portfolio4567 Test-3 Test-4

 

 

Basically, what i need is sheet names as well along with the data.

 

Any help is much appreciated.

 

 

Thanks & Regards

Dilver

 

9 REPLIES 9
davidskaife
14 - Magnetar

Hi @Dilver_Shaik 

 

There is an excellent article here that will help you - https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/The-Ultimate-Input-Data-Flowchart/t...

 

It provides worked examples as well to help tailor it to your specific requirements

binuacs
21 - Polaris

@Dilver_Shaik You need to have two batch macro for this one is for getting all the file names and sheet names and second is for getting the data

 

binuacs_0-1655826777167.png

 

Hi @Dilver_Shaik 

 

Please check the attached. It uses a simple macro to get you the info you are looking for.

 

christine_assaad_0-1655826986796.png

Hope this helps. Cheers!

Dilver_Shaik
7 - Meteor

Hi @christine_assaad  - Thanks for sharing that.

 

I am not much familiar to Macros. Correct me if I am wrong.

 

In the directory tool, I had given the path of the files. Do I need to give the same in the Input data tool inside the Macro?

Hi @Dilver_Shaik 

 

You don't need to change the macro. This is why it's a powerful tool. It's dynamic and can be used with other data sets.

 

This link https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Getting-Started-with-Batch-Macros/t... will give you more info on how to build macros. 

 

Edit: This is a better link that's more relevant to your use case https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/How-To-Import-Multiple-Excel-Sheets...

 

Cheers!

Dilver_Shaik
7 - Meteor

Hi @binuacs  - Thanks for the solution. This works for me. But sheet name is not getting fully. Seems some problem in Regex_replace. Could you please help with that.

binuacs
21 - Polaris

@Dilver_Shaik Can you please check the RegeEx formula reflects like below

binuacs_0-1655888896040.png

 

Dilver_Shaik
7 - Meteor

@binuacs  - It worked. Thank you so much.

Magda_Malka
5 - Atom

Many thanks, very helpful!

Labels
Top Solution Authors