Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
muniyandi
Creator III
Creator III

Loading Multiple CSV File using for loop

Hi Team,

i have to load multiple csv file in single ORDER table .

ex:

I have 4 csv file in my order folder, i want the result in order table should have all the 4 file data.

ORD_AUG_2016.csv

ORD_SEP_2016.csv

ORD_OCT_2016.csv

ORD_NOV_2016.csv

pls suggest best option to load all the data.

Thanks,

Muni

1 Solution

Accepted Solutions
kenphamvn
Creator III
Creator III

Hi

Try this

ORDER:

Load *

from 'filepath\ORD_*.csv;


regards

An Pham

View solution in original post

6 Replies
zhadrakas
Specialist II
Specialist II

try

FOR EACH file in filelist('C:YOURPATH\*.csv') ;
Load * from '$(file)'   (txt, utf8, no labels, delimiter is ' ', msq);
NEXT file

kenphamvn
Creator III
Creator III

Hi

Try this

ORDER:

Load *

from 'filepath\ORD_*.csv;


regards

An Pham

muniyandi
Creator III
Creator III
Author

This script is not working

zhadrakas
Specialist II
Specialist II

probably you Need to edit this paramters to your needs

(txt, utf8, no labels, delimiter is ' ', msq)

but you dont really Need to do that in a Loop. Look at "An Pham's" Solution

muniyandi
Creator III
Creator III
Author

Hi An Pham,

your code has been working , i need to add file_name column also (tracking purpose )

Thanks,

kenphamvn
Creator III
Creator III

Hi

if you want add file_name column you need using Loop condition like Tim Driller Solution

Set v_Concatenate ='';

FOR EACH file in filelist('D:\Temp\CSV\ORD_*.csv') ;

$(v_Concatenate) 

ORDER: 

Load *, Right('$(file)',16) as file_name

from

'$(file)'   (txt, codepage is 1252, embedded labels, delimiter is ',', msq);

set v_Concatenate ='Concatenate'; 

NEXT file

Regards

An Pham