Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

Load multiple excel files with different structure (name file change every time)

Hi everyone,

I have a folder in which i have two source files (xslx files)  and i want to load this files. note that:

- This files are named differently each time,

- This files have different structure, and i don't upload all the columns( i don't do load * )

So how can i load data from this excel files ? without ODBC connection ?

Thank you very much for your help!

Labels (4)
1 Reply
Highlighted
Partner
Partner

Hi

You can use Error variables to handle errors in script.

https://help.qlik.com/en-US/sense/April2019/Subsystems/Hub/Content/Sense_Hub/Scripting/ErrorVariable...

 

For example your script may look like this:

SET ErrorMode=0; // Disable all errors

/* Try to load first format from all files in dirctory */

Table1:

LOAD

Field1,

Field2,

Field3

FROM [lib://YourPath\*.xlsx]
(ooxml, embedded labels, table is Sheet1);

/* Try to load second format from all files in dirctory */

Table2:

LOAD

Field4,

Field5,

Field6

FROM [lib://YourPath\*.xlsx]
(ooxml, embedded labels, table is Sheet1);

SET ErrorMode=1; // Finally set error mode to 1

 

Note the * character in the FROM expression! it will load all files from the directory by mask *.xlsx

Regards, Igor.