Missed the Q4 Fall Release Product Update? Watch the on-demand webinar for more info on the latest in Designer 24.2, Auto Insights Magic Reports, and more!
Free Trial

Alteryx Designer Desktop Discussions

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

extracting sheet names from excel sheets with different schemas

lumjingbki
8 - Asteroid

Hi I have a excel file with different sheets and with different column names I have created a batch macro to extract the sheet details from the file and I am able to append all the data into a single file but I also want the "Sheet names" so that with the help of different sheet names I can segregate the data once the data is extracted as the sheets have different columns. can you please help. 

 

 

4 REPLIES 4
Yoshiro_Fujimori
15 - Aurora
15 - Aurora

Hi @lumjingbki ,

 

In the Dynamic Input tool in the Batch Macro, when you specify "Input Source Data Template",

Yoshiro_Fujimori_1-1683534614098.png

you can configure to "Output File Name as Field" as "Full Path", so that the Full path and Sheet name are output.

Yoshiro_Fujimori_0-1683533675114.png

Then in the main Workflow,

Yoshiro_Fujimori_2-1683534718578.png

you can parse the string to File name and Sheet name with RegEx such as:

SheetName = REGEX_Replace([FileName], ".*\|{3}(.*)", "$1")

FileName = REGEX_Replace([FileName], ".*\\(.*)\|{3}.*", "$1")

 

Output

Yoshiro_Fujimori_3-1683534816484.png

 

Does this work for your case?

lumjingbki
8 - Asteroid

@Yoshiro_Fujimori Thank you for the quick response. am getting "The field "" is missing. Compare the tool configuration with the input stream" error.  In your workflow I notice that there are multiple excel files. In my case I have one excel file and have different sheets with different schemas. I am using batch macros to append the sheet data but I want the sheets names so that I can differentiate the data appended.  

 

lumjingbki_0-1683536669439.png

 

binuacs
21 - Polaris

@lumjingbki Since you have different schema only batch macro works, attaching the sample workflow for your referene

binuacs_0-1683538218806.png

 

someotherguy
8 - Asteroid

@Yoshiro_Fujimori  Thanks for this, didn't realize full path gave the sheet name as well. Had to modify the regex slightly to remove the ` $` that surrounds the table name

 

2023-11-02 18_00_02-Alteryx Designer x64 - SAP - VK11 - KMAT pricing tables 2023-10-24.yxmd.png

 

REGEX_Replace([FileName], ".*\|{3}(.*)", "$1")         before

REGEX_Replace([FileName], ".*\|{3}`(.*)\$`", "$1")    after

 

Labels
Top Solution Authors