Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

dmac1971
Contributor II

Load data from files in an array.

I know its possible to load data from all files in a folder with a specific naming convention, ie *Data.qvd etc.  Is it possible to do something similar but use the file names from an array or table within QV?

Say load all data from :

C:/Data/Jan_Sales.xls

C/Data/Feb_Sales.xls

C/Data/Mar_Sales_Adj.xls

Etc

I'm pulling data from multiple files over google drive and sometimes the files get renamed so would be simplier to correct in one location rather than multiple?  I'm sure you could do it with variables as well, but this would be cleaner for me?

Thanks in advance.

1 Solution

Accepted Solutions

Re: Load data from files in an array.

It's possible, but it requires a variable as well.

// an array

For Each vFile in 'File1.xls','File2.xls','File3.xls'

     MyTable:

     Load * FROM [$(vFile)] (biff, ...etc ...);

Next

// a table, can be any kind of table loaded inline or from a text file, or excel file or database etc.

Files:

LOAD * INLINE [

Filename

C:/Data/Jan_Sales.xls

C:/Data/Feb_Sales.xls

C:/Data/Mar_Sales_Adj.xls

];

For i =1 to NoOfRows(Files)-1

     LET vFile = peek('Filename',$(i),'Files');

     MyTable:

     Load * FROM [$(vFile)] (biff, ...etc ...);

Next

2 Replies

Re: Load data from files in an array.

It's possible, but it requires a variable as well.

// an array

For Each vFile in 'File1.xls','File2.xls','File3.xls'

     MyTable:

     Load * FROM [$(vFile)] (biff, ...etc ...);

Next

// a table, can be any kind of table loaded inline or from a text file, or excel file or database etc.

Files:

LOAD * INLINE [

Filename

C:/Data/Jan_Sales.xls

C:/Data/Feb_Sales.xls

C:/Data/Mar_Sales_Adj.xls

];

For i =1 to NoOfRows(Files)-1

     LET vFile = peek('Filename',$(i),'Files');

     MyTable:

     Load * FROM [$(vFile)] (biff, ...etc ...);

Next

dmac1971
Contributor II

Re: Load data from files in an array.

Gysbert,

Thank you appreciated, fairly simple when you see it like that.  Should improve my script greatly.

Dermot