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: 
benkim
Contributor
Contributor

How to load For Each with 2 If criteria

Hi there, 

I am trying to load multiple CSV with 2 x IF conditions.

Load only IF

 

1. the CSV file name DOES NOT contain 'double', 'single', 'jumbo' 

AND

2. FileTime() > 18/06/2020 - Meaning load the CSV only if the file modified has a date greater than 18/06/2020

But I am not familiar on how to construct the script. 

See my attempt below - The issue is highlighted in red

Set Path = 'C:\TESTING\';

for each File in filelist(Path & '*.csv')

If FileTime() >= Date#('22/06/2020','DD/MM/YYYY') AND

If(NOT(Wildmatch('$(File)', '*double*','*single*', '*jumbo*'))) THEN

Facts:
LOAD

LeadIndicator,
QuoteNo,
Brand

FROM
[$(File)]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq)
;

End If;

Next File;

 

Thank you 

Labels (1)
1 Solution

Accepted Solutions
Taoufiq_Zarra

One solution :

set Path ='./CSV22062020';

FOR each vFile in filelist('$(Path)/*.csv')

let Datecheck=floor(Date(FileTime('$(vFile)')))-floor(Date('18/06/2020'));
let Filechek=wildmatch('$(vFile)','*double*','*single*','*jumbo*');


IF '$(Datecheck)'>=0 and '$(Filechek)'=0 then
	Data:
	LOAD LeadIndicator, 
	     QuoteNo, 
	     Brand
	
	FROM
	[$(vFile)]
	(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
endif
NEXT 
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

1 Reply
Taoufiq_Zarra

One solution :

set Path ='./CSV22062020';

FOR each vFile in filelist('$(Path)/*.csv')

let Datecheck=floor(Date(FileTime('$(vFile)')))-floor(Date('18/06/2020'));
let Filechek=wildmatch('$(vFile)','*double*','*single*','*jumbo*');


IF '$(Datecheck)'>=0 and '$(Filechek)'=0 then
	Data:
	LOAD LeadIndicator, 
	     QuoteNo, 
	     Brand
	
	FROM
	[$(vFile)]
	(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);
endif
NEXT 
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉