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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
EMME_DR
Contributor III
Contributor III

where not WildMatch()

Hi,

in the editor i try to extract only files csv that doesn't contain the word 'ElencoFlussi', but it fails: what can I do?

Regards.

PDR_STG1:
LOAD
Piva_Udb&'|'&Cod_Remi&'|'&Cod_prof_prel_std&'|'&Trattamento&'|'&Annomese&'|'&pdr as key,
pdr&'|'&Annomese as key_flussi,
pdr,
Prelievo,
Piva_Udb,
Dtg,
Cod_Remi,
Id_regione_climatica,
Cod_prof_prel_std,
Trattamento,
Tipo_cliente,
Sessione,
Annomese,
filename() as NomeFile
FROM [lib://SCR_Shared_Folder/Dettaglio PDR - Flussi/*.csv]
(txt, codepage is 28591, embedded labels, delimiter is ';', msq)
where not WildMatch(filename(), 'ElencoFlussi');

exit script;

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer
MVP
MVP

I think you mean this:

for each file in filelist('path\*.csv')
   if not wildmatch('$(file)', '*xyz*') then
      t: load * from [$(file)] (txt, ...);
   end if
next

- Marcus

View solution in original post

10 Replies
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hello,

Try below,

where not WildMatch(filename(), '*ElencoFlussi*');

 

Thanks,
Ashutosh

EMME_DR
Contributor III
Contributor III
Author

No, it extracts all files
marcus_sommer
MVP
MVP

I'm not sure if you could use filename() on the outside of a load - means it's probably empty or NULL.

More suitable within the many scenarios is the use of filelist() instead of your wildcard-load - means something like:

for each file in filelist('path\*.csv')
   if not wildmatch('$(file)', '*xyz*') then
      ... load ...
   end if
next

- Marcus

EMME_DR
Contributor III
Contributor III
Author

what do i set in the 'Set' condition before the loop?
marcus_sommer
MVP
MVP

I think you mean this:

for each file in filelist('path\*.csv')
   if not wildmatch('$(file)', '*xyz*') then
      t: load * from [$(file)] (txt, ...);
   end if
next

- Marcus

EMME_DR
Contributor III
Contributor III
Author

Nope Marcus, the script reads all file and don't exclude the files 'Elenco Flussi'.
marcus_sommer
MVP
MVP

You use it really like above suggested with load * from [$(file)] and replacing xyz with your string? You may also adjust a bit the condition from:

 if not wildmatch('$(file)', '*xyz*') then

to

 if wildmatch('$(file)', '*xyz*') = 0 then

- Marcus

durgesh22
Creator
Creator

Code give above worked for me,, made it more simplified ,try it.Hope it works for you

for each file in filelist('MENTION PATH HERE\*.csv')
if not wildmatch('$(file)', '*Elenco Flussi*') then
t: load * from [$(file)] (txt);
end if
next

EMME_DR
Contributor III
Contributor III
Author

Yes, i replace with the correct info.
I try with your second option but I've the same error:

Caricamento dati iniziato
xxx_yyy_AGG_S1_FIN_202001_20211129124442_1 Linee recuperate: 502 02698620347_01219980529_AGG_S1_FIN_202001_20211129124442_1 << xxx_yyy_AGG_S1_FIN_202002_20211129124442_1 Linee recuperate: 999 02698620347_01219980529_AGG_S1_FIN_202001_20211129124442_1 << xxx_yyy_AGG_S1_FIN_202003_20211129124442_1 Linee recuperate: 1.492 02698620347_01219980529_AGG_S1_FIN_202001_20211129124442_1 << xxx_yyy_AGG_S1_FIN_202004_20211129124442_1 Linee recuperate: 1.980
Si è verificato il seguente errore:
Field 'Piva_Udb' not found
L'errore si è verificato qui:
LOAD Piva_Udb&'|'&Cod_Remi&'|'&Cod_prof_prel_std&'|'&Trattamento&'|'&Annomese&'|'&pdr as key, pdr&'|'&Annomese as key_flussi, pdr, Prelievo, Piva_Udb, Dtg, Cod_Remi, Id_regione_climatica, Cod_prof_prel_std, Trattamento, Tipo_cliente, Sessione, Annomese, filename() as NomeFile FROM [lib://SCR_Shared_Folder/Dettaglio PDR - Flussi/*.csv] (txt, codepage is 28591, embedded labels, delimiter is ';', msq)
I dati sono stati caricati. Correggere l'errore e riprovare a caricare.

If you read the error message, qlik is able to load files but stops when it finds files '*Elenco Flussi*'

When you read 'Field 'Piva_Udb' not found' it's because the paths the 2 type of files are different