Discussion Board for collaboration on QlikView Scripting.
This is part of my script:
for each FoundFile in filelist( Root & '\*.csv')
let vTemp= '$(FoundFile)';
let vTemp2= upper(left(filename('$(FoundFile)'),len(filename('$(FoundFile)'))-21));
The result is:
I'm trying to isolate the file name without the date stamp, extension and folders and to show it in upper case letters.
where am I wrong?
Go to Solution.
Sorry, my mistake:
let vFileName = mid('$(FoundFile)', index('$(FoundFile)', '\', -1) +1);
let vTemp2= upper(left('$(vFileName)', len('$(vFileName)') -21));
I dont think you need the single quotes around your $(Foundfile) declarations.
If I remove them then I don't get event a result for vTemp
Sorry I misread the double quotes in your question. The issue is the filename function. It only works when loading data from a file. You should just look at using normal string functions.
LET vTemp2 = UPPER(RIGHT('$(vTemp)'),20);
You don't need to use expansions in these expressions, and filename() only works in a LOAD statement. Rather use subfield(), like this:
for each vFoundFile in filelist( Root & '\*.csv')
Let vTemp1 = SubField(vFoundFile, '\', -1); // file name including extension
Let vTemp2 = SubField(SubField(vFoundFile, '\', -1), '.', 1); // file name excluding extension
filename() function works only in a LOAD statement (see help). To extract the filename I would suggest to use index():
let vTemp2= upper(left('$(FoundFile)', len('$(vFileName)') -21));
Ok, but now I get the file name without the extension but with the date stamp.
how can I remove the date stamp?
if I use right function then I get the time stamp.
if I use left function I get partial names because each file has different name.
how can I remove only the date stamp and to get finally this result for the current path:
get only c:\dec
If it is a constant length then use left/right/mid functions to select what you need. If it is variable length then use the subfield function.