Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using FileTime with willdcard

Hello

I have troubles in using wildcard in the path of the specified file.

Files are deposited in a folder through an automatic job and the files are called 'YYYYMMDD HHMMSS stock quantity.xls'

Obviously, everyday the YYYYMMDD HHMMSS part is changing, thus I was applying this:

Let vStock = FileTime( '\\location\drive$\folder\*stock quantity.xls');

but indeed QV does not seem to like the wildcard in this syntax.

Can you please help me out?

thank you!

1 Solution

Accepted Solutions
Gysbert_Wassenaar

No need to load a table. This will do:


For each vFileName in Filelist ('\\location\drive$\folder\*.xls') 

     Let vStock = FileTime('$(vFileName)');

// or vStock = '$(vFileName)' if you want the file name instead of its modification date

Next


talk is cheap, supply exceeds demand

View solution in original post

7 Replies
Gysbert_Wassenaar

Filetime can only return one value. And a variable can also have only one value. The wildcard can match more than one file so that's not valid. Either use the exact file name or create a loop that loops through the files and return the filetime for each file. See this blog post: Loops in the Script


talk is cheap, supply exceeds demand
Not applicable
Author

bad news for me!

so in my case, if I have just this one file in the folder (every day the yesterday's one get deleted and the new one is deposited), I would need to:

- create a for each so to loop through that one file (!!)

For each vFileName in Filelist ('\\location\drive$\folder\*.xls')

      Load '$(vFileName)' as FileName

      From [$(vFileName)];

   Next vFileName

- then load that in a variable

Let vStock = FileName()

would it be something like this?

thank you!

Gysbert_Wassenaar

No need to load a table. This will do:


For each vFileName in Filelist ('\\location\drive$\folder\*.xls') 

     Let vStock = FileTime('$(vFileName)');

// or vStock = '$(vFileName)' if you want the file name instead of its modification date

Next


talk is cheap, supply exceeds demand
Not applicable
Author

super mooi!

will give it a try and let you know the outcomes tomorrow, thank you!

Not applicable
Author

I am trying this on a dummy dashboard in the meantime and, to be honest, I have couple files in the same folder

So I did

For each vFileName in Filelist ('\\location\drive$\folder\*.xls') 

     Let vStock = FileTime('$(vFileName)');


Next


For each vFileName2 in Filelist ('\\location\drive$\folder\*.csv') 

     Let vStock2 = FileTime('$(vFileName2)');


Next

but it is not working properly.

The right file names are stored into vFilaName and vFileName2, but the FileTime function for some reason is working just for the first file.

So, vStock has the timestamp, meanwhile vStock2 is generated empty.

Am I doing something wrong here?

thank you very much!

Gysbert_Wassenaar

No idea. Your code looks correct and it works for me.


talk is cheap, supply exceeds demand
Not applicable
Author

Gysbert Wassenaar wrote:

No idea. Your code looks correct and it works for me.

yep.

there is something systematically wrong with those files.

I tried with another random *.csv and it is working as expected.

tomorrow will update the answer status, thank you!