Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Serious error in function DoDir(Root)

Below I've enclosed the example script from QlikView help. This function lists all files in certain location (in this case on drive C:). But it's very sensitive to one thing:

Your's_best_file.qvw

This file contain an apostrophe , which causes error during the execution of this function, when this file will be found. Unfortunelly I have no idea what to do with it.

If anybody can help me, it would be very kind of you.

************************************************************************

[ code ]

// list all QV related files on disk

sub DoDir (Root)

for each Ext in 'qvw', 'qva', 'qvo', 'qvs'

for each File in filelist (Root&' \*.' &Ext)

Load '$(File)' as Name, FileSize( '$(File)' ) as

Size, FileTime( '$(File)' ) as FileTime

autogenerate 1;

next File

next Ext

for each Dir in dirlist (Root&' \*' )

call DoDir (Dir)

next Dir

end sub

call DoDir ('C:')

[/ code ]



3 Replies
Not applicable
Author

I would change the name of the file; apostrophes in file names are not permitted. Can it not be changed?

Not applicable
Author

Well the problem is that it cannot be changed. Maybe there is another way ?

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Pawel,

the problem is caused by the statement where $(File) is enclosed in a set of single quotes, and the structure all together doesn't work. Try the following code, it "MIGHT" work, because $(File) is not wrapped in quotes:


Main:
Load
Name,
Right(Name,Len(Name)-Index(Name,'\',-1)) AS File,
FileSize(Name) as Size,
FileTime(Name) as FileTime,
date(subfield(FileTime(Name),' ',1),'M/D/YY') as FileDate,
year(FileTime(Name)) as FileYear;

Load * Inline [
Name
$(File)] ;