Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dmac1971
Creator III
Creator III

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
Gysbert_Wassenaar

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


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

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


talk is cheap, supply exceeds demand
dmac1971
Creator III
Creator III
Author

Gysbert,

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

Dermot