Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load same file from a number of folders

Hi,

I am attempting to load a file which appears in a number of date folders but I keep getting a syntax error.

Imagine the directory like this:
20131404 > Registrations.csv
20131504 > Registrations.csv

So what I am trying to achieve is to loop through each date folder and load the Registrations.csv.

I am using From "Test\*\Registrations.csv" - is this the correct method to use?

Any help is much appreciated

6 Replies
Gysbert_Wassenaar

Something like this maybe:

for each SubDirectory in dirlist( 'D\MyDate\*' )

     Table1:    

     load * from $(SubDirectory)\Registrations.csv (txt, codepage is 1252, embedded labels);

next SubDirectory


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert,


Thanks for the reply.


I tried this out however it doesn't seem to recognise the * in the directory string.


I have put 'C:\Users\eaamk\Desktop\Qlikview Report\*' as the dirlist and I receive an error saying file not found.

When I reload the report the error message identifies the location as 'C:\Users\eaamk\Desktop\Qlikview Report\Registrations_Agent_Extract.csv'.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this.

SUB DoDir (Root)

Load * from Registrations_Agent_Extract.csv ;

NEXT Ext

FOR Each Dir in dirlist (Root&'\*' )

call DoDir (Dir)

NEXT Dir

ENDSUB

CALL DoDir ('C:')

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi Kaushik,

I have tried using this sub-routine a few ways but the structure below seems to only return one error.
The error shows that qlikview doesn't recognise the *.


set Root="C:\Users\eaamk\Desktop\Qlikview Report\*\";

SUB DoDir (Root)

FOR Each Dir in dirlist (Root)

Load * from Registrations_Agent_Extract.csv ;

call DoDir (Dir)

NEXT Dir

ENDSUB

CALL DoDir ('C:\Users\eaamk\Desktop\Qlikview Report').


I've tried adding in the name of the sub-directory instead of the * and this runs ok but nothing is loaded from the CSV.

Anonymous
Not applicable
Author

Hi,
try this:

SUB DoDir (Root)

For each File in filelist (Root'\*Registrations*.csv')

Load

     *

FROM

     $(File) ;

NEXT File

For each Dir in dirlist (Root&'\*')

CALL DoDir (Dir)

NEXT Dir

ENDSUB

CALL DoDir ('C:\Users\eaamk\Desktop\Qlikview Report')

Anonymous
Not applicable
Author

Hi,
try this:

SUB DoDir (Root)

For each File in filelist (Root'\*Registrations*.csv')

Load

     *

FROM

     $(File) ;

NEXT File

For each Dir in dirlist (Root&'\*')

CALL DoDir (Dir)

NEXT Dir

ENDSUB

CALL DoDir ('C:\Users\eaamk\Desktop\Qlikview Report')