Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

spividori
Valued Contributor

Read existing files

Hi.

I need to read the names of existing files in a specific folder and load them into a table.

I solve QlikView as follows:

SET FilePath='*.qvd';

sub DoDir (Dir)

for each File in filelist (Dir&'\'&'$(FilePath)')

SET sFile = $(File);

    NomFile:

     First 1 LOAD

     FileTime() As FileTime,

     FileName() As FileName,

     Left(FileName(),1) as FId,

     left(Right(FileName(),12),8) as FNom

    from [$(sFile)];

   next File

end sub;

call DoDir ('C:\Users\Qsense');

But with Qlik Sense not working. Any suggestions?.

Regards.

1 Solution

Accepted Solutions

Re: Read existing files

Hi Sandro, in Sense you have to create a connection to a folder using the button on the right side of the script panel:

Then you can use this script:

SET FilePath='*.qvd';

sub DoDir (Dir)

for each File in filelist ('$(Dir)\$(FilePath)')

SET sFile = '$(File)';

    NomFile:

     First 1 LOAD

     FileTime() As FileTime,

     FileName() As FileName,

     Left(FileName(),1) as FId,

     left(Right(FileName(),12),8) as FNom

    from [$(sFile)];

   next File

end sub;

call DoDir ('lib://YourConecctionName\OptionalMorePath');

2 Replies

Re: Read existing files

Hi Sandro, in Sense you have to create a connection to a folder using the button on the right side of the script panel:

Then you can use this script:

SET FilePath='*.qvd';

sub DoDir (Dir)

for each File in filelist ('$(Dir)\$(FilePath)')

SET sFile = '$(File)';

    NomFile:

     First 1 LOAD

     FileTime() As FileTime,

     FileName() As FileName,

     Left(FileName(),1) as FId,

     left(Right(FileName(),12),8) as FNom

    from [$(sFile)];

   next File

end sub;

call DoDir ('lib://YourConecctionName\OptionalMorePath');

spividori
Valued Contributor

Re: Read existing files

Hola Rubén.

Funcionó perfecto, gracias.

Saludos.

Sandro.