Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
beaubellamy
Partner - Contributor III
Partner - Contributor III

error msg when using DirList

Qlicksenese desktop June 2019

I am trying to loop through some directories to read a single file. Each directory will have the same file available in it, 'trip_end_details.csv'.  I've found a few posts on how to do it, but none of them work

The folder structure is:

C://..../NetworkSim/folder1/n/trip_end_details.csv

C://..../NetworkSim/folder2/n/trip_end_details.csv

Where n is a number from 0 - 9, My load scripts is below:

 

SET NWS_base_folder = 'lib://some_path/NetworkSim/';

For each vSubDir in DirList('$(NWS_base_folder)')
    For sim_no = 0 to 9
        LOAD
        *
        FROM [$(NWS_base_folder)/$(vSubDir)/($sim_no)/trip_end_details.csv]
        (txt, codepage is 28591, embedded labels, delimiter is ',', msq);
    Next
Next

 

My problem is, No data is being loaded. I have tried the load script for each subfolder, and this loads the data.

I've tried setting the base_folder to the full path on the drive, ie 'C:\Users\.....\NetworkSim\'

Can someone tell me what i'm doing wrong?

Labels (2)
1 Solution

Accepted Solutions
Rodj
Luminary Alumni
Luminary Alumni

I believe DirList returns a fully qualified directory name, so you don't need to build it again yourself. Also you need to add a '*' wildcard to the end of your root directory.

Try something like this to see the list of directories:

for each vDir in Dirlist('$(vPath)'&'\*')
         Trace 'Directory is: $(vDir)';

        // put your load statement here.
next

 

Cheers,

Rod

View solution in original post

3 Replies
Anil_Babu_Samineni

QlikSense works on Library connection.

SET NWS_base_folder = 'lib://some_path/NetworkSim/'; // some_path is the connection name, I assume. Is that understood by me correctly?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
beaubellamy
Partner - Contributor III
Partner - Contributor III
Author

Not exactly. 

Lib://some_path/NetworSim is the library path and all the subfolder's i want are underneath this directory

Rodj
Luminary Alumni
Luminary Alumni

I believe DirList returns a fully qualified directory name, so you don't need to build it again yourself. Also you need to add a '*' wildcard to the end of your root directory.

Try something like this to see the list of directories:

for each vDir in Dirlist('$(vPath)'&'\*')
         Trace 'Directory is: $(vDir)';

        // put your load statement here.
next

 

Cheers,

Rod