Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello there
I'm trying a subroutine to enlist all files in a directory based on a couple of extensions. My load script is pretty simple (took it from Qlik help):
sub DoDir (Path)
For Each Ext in 'qvw', 'qvo', 'qvs', 'qvt', 'qvd', 'qvc'
For Each File in filelist (Path&'\*.' &Ext)
LOAD
'$(File)' as Name,
FileSize( '$(File)' ) as Size,
FileTime( '$(File)' ) as FileTime,
FileDir( '$(File)' ) as Directory,
FileName( '$(File)' ) as FileNm,
FileExtension( '$(File)' ) as Extension
autogenerate 1;
Next File
Next Ext
For Each Dir in dirlist (Path&'\*' )
Call DoDir (Dir)
Next Dir
End Sub
Call DoDir ('D:\#1Benazir\Qlik')
I get the following table
Why are three of the functions not returning any values?
Rgds,
Benazir
Only FileTime() accepts an optional filepath. The other functions do not take a filepath, they are applied to the file being loaded in a load statement. Replace your load with something like this
First 1 LOAD
'$(File)' as Name,
FileTime() as FileTime,
FileSize() as Size,
FileDir() as Directory,
FileName() as FileNm
FileExtension() as Extension
FROM [$(File)] (.....)
You cannot use FileName(), FileDir() and FileExtension() with autogenerate because these functions supports only folder data connection in standard mode.
Only FileTime() accepts an optional filepath. The other functions do not take a filepath, they are applied to the file being loaded in a load statement. Replace your load with something like this
First 1 LOAD
'$(File)' as Name,
FileTime() as FileTime,
FileSize() as Size,
FileDir() as Directory,
FileName() as FileNm
FileExtension() as Extension
FROM [$(File)] (.....)
Thank you so much Michele and Jonathan!
What do you mean by standard mode?
It means to use DataConnection in the script and not relative or absolute path.
Refer to the below link for details: