Alteryx Designer Desktop Discussions

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

Creating a list of all excel sheets in a directory

carrera
5 - Atom

Hi all,

 

I am a total newbie in Alteryx Designer and need your help. I would like to create a list with all sheets of excel files from a directory. I am not interested in the content of the sheets (yet). I just want a list in the form:

 

RecordSheet NamesPath
1Sheet 1...\file1.xlsx|||'Sheet 1$'
2Sheet 2...\file1.xlsx|||'Sheet 2$'
3Sheet 3...\file1.xlsx|||'Sheet 3$'
4Sheet 1...\file2.xlsx|||'Sheet 1$'
5Sheet 2...\file2.xlsx|||'Sheet 2$'
6Sheet 1...\file3.xlsx|||'Sheet 1$'
7Sheet 1...\file4.xlsx|||'Sheet 1$'
.........

I tried a batch macro for this: Read in Multiple Excel Files, with Multiple Tabs that have Different Schemas (alteryx.com) but omitted the second part (macro), since I don't want to open the sheets.

Unfortunately, this does not work as desired. Does anyone have an idea how to solve this?



13 REPLIES 13
JoshuaB
Alteryx Product Evangelist
Alteryx Product Evangelist

Yes. Yes, and This is correct @apathetichell  ;) Just don't want users to jump to a batch macro IF it's not necessary ;) 

Joshua Burkhow | Chief Evangelist @ Alteryx | Follow me on LinkedIn and Twitter
vbmike73
7 - Meteor

But I'm not interested in the content of the sheets. I only want a list of the sheet names from each file. However, it seems that if the files are different, I get the schema error. This method only appears to work for Excel files with the same types of sheets maybe? What's odd is that if I take the same file, and make copies of it while adding different sheets to each file, this method will work. Can't figure this out.

apathetichell
18 - Pollux

Hi - I think there is some confusion here... i don't know what "This method only appears to work for Excel files with the same types of sheets maybe" means here... If you are reading sheet names only - <List of Sheet Names> works for every .xlsx file - this does not work for .xls - which is a totally different format.

 

If you are reading in the columns - ie the schema of the sheet - you are reading in data from the sheet - and you have to use a batch macro approach if the schema on the sheets (or the files) is (are) different. It doesn't matter if you are reading the data in the columns or the column headers - you need to do this. If you just want .xlsx sheet names - @JoshuaB 's method will work.

vbmike73
7 - Meteor

Appreciate the help, but I think this is not entirely true. After more research, I've learned that the schema error comes from the max sheet name length. If the max sheet name length is not the same for every XLSX file in the folder, you will get the schema error. So if one file has a single sheet that has a 10-character name, and another file has a single sheet with a 12-character name, you get the error. As soon as I added a sheet to all my files that had a 15-character name (the name itself is irrelevant), then it worked just fine. It's an odd error, but at least I know now what is causing it. And if anyone else needs to know, the max sheet name length for an Excel sheet is 31 characters, but this really has nothing to do with the cause of this error.

 

Thanks to everyone for the help!

Labels