Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

check for File name followed by something

I am trying to check if an excel file starting with something exists in a given folder. The following part of the file name is month so I want to keep it dynamic. Could anyone please help me achieve that?

My code is :

Let vFilename = 'Data_2014' ;

Call FileCheck(vFilename, vSourceFolder, vExists);

If vExists then

set vDataFile = 'Yes' ;

else

set vDataFile = 'No' ;

end if

FileCheck is a subroutine I have created for this purpose.

I don't want to use the for each loop as it if there's no file then it does not enter the loop and hence the value of variable vDataFile remains unchanged.

PS: I am unable to paste my qlikview code(or anything) else in this Create(start a discussion) window. Any clue as to why this could be happening?

2 Replies
datanibbler
Champion
Champion

Hi,

but you will have to use some kind of loop to enter the subroutine once for every file you find in that location, no?

It's certainly true that if there's no file matching your search_mask, then that loop will not enter the subroutine, so you have to account for that possibiltiy in your code.

Could you just type an example of what the filenames look like and how exactly you want to handle it?

I guess you will have to include the creation of the complete filename to look for in the loop if a part of the filename is to be dynamic.

Best regards,

DataNibbler

Not applicable
Author

I figured it out. putting the check outside the loops work totally fine.