Skip to main content

Connectivity & Data Prep

Discussion board where members can learn more about Qlik Sense Data Connectivity.

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
aritting
Creator
Creator

How do you check if a file exists in a LIB in load script on Qlik SAAS?

 

I have this QlikView and Qlik Sense Enterprise code that checks for a fieldmap file and remaps column names

Is there a way to check if a file exists in a lib on Qlik Sense SAAS? using either the datafile lib or an Amazon S3 lib?

 call vL.FileExist ('$(vG.ImportPath)\fieldmap-$(vL.TrimmedDocName).csv'); //Validate if cache exist
if vL.FileExist='true' then
// Remap the fields with descriptive names
[FieldMap$(vL.TrimmedDocName)]:
MAPPING LOAD
ExistingFieldName,
UserFriendlyFieldName
FROM
[$(vG.ImportPath)\fieldmap-$(vL.TrimmedDocName).csv]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq)
WHERE len(UserFriendlyFieldName)>0;
RENAME FIELDS USING [FieldMap$(vL.TrimmedDocName)];
endif 

 

Labels (2)
3 Replies
joseph_morales
Creator II
Creator II

Hi @aritting 

You can try with the filezise() function

Where you can replace the vPath variable with the data connection and vFile with the file inside the data connection

LET vPath ='lib://Dropbox/Files/';
LET vFileName ='Crostable.xlsx';

If FileSize('$(vPath)$(vFileName)') THEN

TRACE File exists $(vPath)$(vFileName);

Table:
LOAD
    Salesman,
    "Year",
    Jan,
    Feb,
    Mar,
    Apr,
    May,
    Jun
FROM [$(vPath)$(vFileName)]
(ooxml, embedded labels, table is Sheet1);

Else

TRACE File does not exist $(vPath)$(vFileName);

End If

 

Best Regards,
Joseph Morales
aritting
Creator
Creator
Author

Does this work in Qlik Cloud?  So far in my testing the answer is no.

joseph_morales
Creator II
Creator II

@aritting 

Yes, it works on my Qlik Cloud

qlik cloud.PNG

 

Best Regards,
Joseph Morales