Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to import files from a directory.
I'm using the following script:
let vFolderPath = 'lib://LOR';
for each file in FileList(vFolderPath & '/*.xls')
LOAD*
FROM $file (txt, unicode, no labels, delimiter is '\t', msq, header is 10 lines);
next file
But when i do so i get this error:
I've also tried using HIC's script, Re: loop through to load all files from a folder and its subfolders?
But still I cannot get it to work!
Anyone got any tips?
I think you should try to load a single file from this folder with the table-wizard. Then you will get the correct syntax for the fields and the file-format and of course you will see if you could access this folder and the files there. If this worked you could wrap the loop-logic around it.
- Marcus
Make sure that your lib is a valid path and you need to modify the variable-call like in tis way:
for each file in FileList('$(vFolderPath)' & '/*.xls')
Further I noticed that you want to load xls-files but your file-format is from txt-files.
- Marcus
Hi,
My path is a folder on our joint server, looking like this:
It is a valid path when I use other ways of reaching it.. 😕
I've also tried this, however it does not seem to work neither,
It cannot find any files, so the number of rows loaded is 0...
Could it be a firewall issue or something?
FileList:
LOAD
'' AS SourceFile
AUTOGENERATE 0;
sub ScanFolder(Root)
for each FileExtension in 'qvw'
for each FoundFile in filelist( Root & '\*.' & FileExtension)
FileList:
LOAD '$(FoundFile)' as SourceFile
AUTOGENERATE 1;
Set vConcatenate = Concatenate;
next FoundFile
next FileExtension
for each SubDirectory in dirlist( Root & '\*' )
call ScanFolder(SubDirectory)
next SubDirectory
end sub
Call ScanFolder('\\FS06\Users6\A63434\Skrivbord\Mål och Mina Listor\Qlick Analys\LOR uppföljning\XXX') ;
I think you should try to load a single file from this folder with the table-wizard. Then you will get the correct syntax for the fields and the file-format and of course you will see if you could access this folder and the files there. If this worked you could wrap the loop-logic around it.
- Marcus
Hi Marcus,
I've actually tried this before posting on the forum, unfortunately!
Connecting with the wizard renders the following "lib link" [lib://LOR/LOR 201601.xls]
I've tried using the 'lib://LOR as "root" and then changed the "\" to a "/" since the wizard wants it to be "/"?
Rendering the following:
Root = 'lib://LOR'
for each FoundFile in filelist( Root & '\*.xls')
LOAD*
FROM $file (xls, unicode, no labels, delimiter is '\t', msq, header is 10 lines);
next file
This "should" work then right?
Kind regards
Hi Again Marcus,
Thanks for your time!
Somehow changing the script once again made it work. Not quite sure what I missed last time but using the wizard rebuilding the script around the new lib connector made it work!
Thanks!
Cheers
I think you will need to change the settings from the legacy mode to be able to use advanced paths: Qlik Sense Legacy mode.
- Marcus