Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
EvanBarrick
Creator
Creator

Load all Excel Files in a Directory

I have a directory that contains excel files, that is updated upon conclusion of events. I want to load all of the files in the directory into a QVD file. I understood how to do this in Qlikview however I am new to Qlik Sense and am struggling to accomplish this. Any help is appreciated. Current structure of script below:

 


Directory 'F:\WaitTimes';


For each ExcelFile in filelist ('*.xlsx')
WaitTimesData:
BUFFER (incremental) Load * From $(ExcelFile) (ooxml, embedded labels, table is [WaitTimes]);
Next ExcelFile;


STORE WaitTimesData INTO [F:\DataAgg\WaitTimesAggregate.qvd] (qvd);

1 Solution

Accepted Solutions
rwunderlich
MVP
MVP

Create a folder connection that points to the directory.  Then use just the filename portion in the From

For each ExcelFile in filelist ('lib://mydir/*.xlsx')

Let fname = SubField('$(ExcelFile', '\', -1);

LOAD ... From lib://mydir/$(fname)

 

Even easier may be to forgo the For loop and use wildcards:

WaitTimesData:
BUFFER (incremental) Load * From lib://mydir/*.xlsx  (ooxml, embedded labels, table is [WaitTimes]);

 

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

5 Replies
rwunderlich
MVP
MVP

Create a folder connection that points to the directory.  Then use just the filename portion in the From

For each ExcelFile in filelist ('lib://mydir/*.xlsx')

Let fname = SubField('$(ExcelFile', '\', -1);

LOAD ... From lib://mydir/$(fname)

 

Even easier may be to forgo the For loop and use wildcards:

WaitTimesData:
BUFFER (incremental) Load * From lib://mydir/*.xlsx  (ooxml, embedded labels, table is [WaitTimes]);

 

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

EvanBarrick
Creator
Creator
Author

Thank you for the help. I had the folder created, however when I run the script I get the error of  'Connection not found'

 

I created the connection and named 'WaitTimesData'

 

The actual directory path is E:\Data\WaitTimes

 

Which title do I use in the from portion

EvanBarrick
Creator
Creator
Author

For context, the option you provided that I utilized

WaitTimesData:
BUFFER (incremental) LOAD * FROM lib://WaitTimesData/*.xlsx (ooxml, embedded labels, table is [WaitTimes]);

rwunderlich
MVP
MVP

Start by loading a single file using the select from connection button.  Then modify the filename in the generated statement to use "*". 

 

-Rob

EvanBarrick
Creator
Creator
Author

Your original answer worked, I had a small error on my end that took some time to notice. Thanks for the help.