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

Different format file loading

Hi Experts,

I have one folder name like "DATA", in my folder i have 10 sub folders like "1,2,....10" in each sub folder having  same field names,

but format is different like "xlsx,csv,txt,xlsx"  how can i load all files at a time?

Regards

Mahesh

8 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

You will need to load each file type with a different load statement as the file type qualifier differs. You could loop over the file types, or do the load in steps;

     For Each vFile in (....*.xlsx)

          ...load xlsx

     Next

     For Each vFile in (....*.csv)

          ... load csv

     Next

Or get the file extension and set a variable to the correct file qualifier, and use the variable as the qualifier. The syntax checker will probably show errors.

     vExt = SubField(vFile, '.', -1)

     if vExt = 'xlsx' then

          Set vQual = (ooxml, embedded labels, sheet is Sheet1);

     else if vExt = 'csv' then

          Set vQual = (txt, ....)

     etc

     end if

     LOAD ...    

     FROM $(vFile)

     $(vQual);

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
marcus_sommer

You could use a loop with dirlist and filelist (within the help is a good example of them by the topic of for each ...) and within them you could check the extension within a if-loop or a pick(match()) combination with a string-function like subfield() or the file-function fileextension(). Here a more practically example: Re: Declaration of code lines.

- Marcus

qlikview979
Specialist
Specialist
Author

Hi Bro,

I need to load all files in single load statement.

Regards

marcus_sommer

This could be considered as one single-loadstatement with an overhead-loop through the folder/subfolder and checking the extension within a variable with returning the appropriate file-format statement which then is used in your real load-statement - and there won't be an easier way ...

- Marcus

qlikview979
Specialist
Specialist
Author

Hi Bro,

is there any Process?

Regards

marcus_sommer

What do you mean with "Process"?

qlikview979
Specialist
Specialist
Author

Hi Bro,

Any easy way to load all files in a single load statement.

marcus_sommer

Please read the above mentioned suggestions again - and yes you will need some own efforts to understand the logic and to adapt it to your own folders/files.

- Marcus