Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Cleaner code with relative path

I am aware that i can use "..\" to call the folder before it. But is there a way such that i do not have to write out so many relative paths and end up writing something like "..\..\..\..\..\"

I know there is a way to do this. But i can't seem to find it. I hope somebody can answer my question.

I just need to access the various folders from the directory. I would prefer to assign it to each variable to make other coders have an easier time understanding my work.

DIRECTORY C:\Users\muzamirnasir\Desktop\Mini Project\Prototype1\Resident Survey\Data\Data\Programs;

LET vErrorProgramPath = 'C:\Users\muzamirnasir\Desktop\Mini Project\Prototype1\Resident Survey\Data\Data\Programs\Error';

LET vStoreProgramQVD = 'C:\Users\muzamirnasir\Desktop\Mini Project\Prototype1\Resident Survey\Data\Data\Programs\QVD\';

LET vStoreProgramBackup ='C:\Users\muzamirnasir\Desktop\Mini Project\Prototype1\Resident Survey\Data\Data\Programs\Backup';

LET vRootFolderPath = 'C:\Users\muzamirnasir\Desktop\Mini Project\Prototype1\Resident Survey\Data\Data\Programs\All Programs';

LET vFileExtension ='*xls';

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This is precisely the way most experienced developers manage the paths. Assign the paths to variables using LET or SET and then reference the variable in the LOAD statement.

LOAD *

FROM [$(vRootFolderPath)]\mydata.xls

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This is precisely the way most experienced developers manage the paths. Assign the paths to variables using LET or SET and then reference the variable in the LOAD statement.

LOAD *

FROM [$(vRootFolderPath)]\mydata.xls

Not applicable
Author

Thanks Rob,  Basically assigning the root folder to a variable made things cleaner and it works perfectly.

So now i wrote it as this.

LET vRootMasterPath ='C:\Users\muzamirnasir\Desktop\Mini Project\Prototype1\Resident Survey\Data\Master';

  LET vErrorMasterPath ='$(vRootMasterPath)\Error';

  LET vStoreMasterQVD ='$(vRootMasterPath)\QVD\';