Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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
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?
Not exactly.
Lib://some_path/NetworSim is the library path and all the subfolder's i want are underneath this directory
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