Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
jjohnstonti618
Contributor III
Contributor III

Ignoring apostrophes in folder name

I am familiar with keepchar, purgechar, and a few other methods utilized to deal with special characters with normal fields; however, my documentpath and file name have an apostrophe in them and are loaded using variables.

//Client name in this case is Bob's Apples and the code knows to automatically look in a preceding folder to find the client name.

/*Code to define your client name based on folder structure--works fine

Let vClientName = SubField(DocumentPath(),'\',substringcount(DocumentPath(),'\'));

// 2 files loaded from 2 different folders depending on which step of the process were in (1 or 2)...these also load fine for Bob's Apples

Let vStepOneFile = chr(39) & 'T:\clients\$(vClientName)\1-Actuals\Actuals Final.xlsx' & chr(39);

Let vStepTwoFile = chr(39) & 'T:\clients\$(vClientName)\2-Benchmark Rates\Benchmark Rates Final.xlsx' & chr(39);

//These fail when my client name has an apostrophe, such as the case with Bob's Apples.  It accounts for the apostrophe when i set the client name variable, as well as when i load the files from a folder name WITH an apostrophe, but thats it. 

Let vStepOneFileExists=if(FileSize($(vStepOneFile))>0,-1,0);

Let vStepTwoFileExists=if(FileSize($(vStepTwoFile))>0,-1,0);

The error i get reads:

Syntax error

Unexpected token: 's', expected nothing

Let vStepOneFileExists=if(FileSize('T:\clients\Bob'>>>>>>s<<<<<< Apples\Actuals\Actuals Final.xlsx')>0,-1,0);

Any ideas?

11 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Nice solution as always from Sunny.  Note that you can get the last folder in the path by using a negative index in substring:

SubField(DocumentPath(),'\',-2)

A little neater than the substringcount().

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

sunny_talwar

Thanks Rob!!! Looking forward to meeting with you at the Qonnections