Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Partner
Partner

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
New Contributor III

Re: error msg when using DirList

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

Re: error msg when using DirList

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?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Partner
Partner

Re: error msg when using DirList

Not exactly. 

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

Rodj
New Contributor III

Re: error msg when using DirList

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