Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loading and storing of dynamic csvs to qvds

Hello all,

I have monthly csvs(24 csvs with monthly names) in one folder, which I have to load to appropriate monthly qvds.

I want to make a loop of loading these csvs.

Can anybody help me to build a procedure which loads csvs in a loop to qvds with the same names like csvs?

Thanks a lot!

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This line is wrong:

for each File in filelist (C:\Users\innas\Desktop\Qvd\QV_new\daily\ &'\'&'$(FilePath)')

Change it to this:

for each File in filelist ('C:\Users\innas\Desktop\Qvd\QV_new\daily\' & FilePath)

You also do not need this line:

SET sFile = '$(File)';


Just use File where you were using sFile.

Hope that helps

Jonathan

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

View solution in original post

14 Replies
rajni_batra
Specialist
Specialist

FOR i = 1 to 12

LET vFileName = 'file' & '$(i)' & '.csv' ;

sales_table:

LOAD ....

FROM $(vFileName) (ansi, fix, no labels, header is 0, record is line) ;

NEXT

or some thing like this...

Not applicable
Author

ok, I understood. But how do I do store to (?)qvd?How I make dynamic name to qvd?

rajni_batra
Specialist
Specialist

not possible because as per my understanding all fields name are same so they will get concate automatically.

will get store in a single QVD only....

u can add a flag by using filename() or filebasename()

hope to help!!!!

Not applicable
Author

Thanks a lot!!!

Not applicable
Author

Hi,

I am trying to do the following:

SET

ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='$#,##0.00;($#,##0.00)';

SET TimeFormat='h:mm:ss TT';

SET DateFormat='M/D/YYYY';

SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';









SET FilePath='*.csv';

set vFileName = 'file';



for each File in filelist (C:\Users\innas\Desktop\Qvd\QV_new\daily\ &'\'&'$(FilePath)')

   
SET sFile = '$(File)';

   
Directory;

   NetworkDomainDailyData:

   
LOAD *

   
FROM

    [$(sFile)]

    (
fix, codepage is 1252);



store * from NetworkDomainDailyData into C:\Users\innas\Desktop\Qvd\Sql_Data\$(vFileName).qvd(qvd);

drop table NetworkDomainDailyData;



   
next File

   

   
exit script;

and it does not load/store anything.

Where is my mistake?

rajni_batra
Specialist
Specialist

can u share the name of ur .csv files so that i could try it

Not applicable
Author

Hi,

one of the csv files look like:

C:\Users\innas\Desktop\Qvd\QV_new\daily\ra_daily.csv

Thanks!!!

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This line is wrong:

for each File in filelist (C:\Users\innas\Desktop\Qvd\QV_new\daily\ &'\'&'$(FilePath)')

Change it to this:

for each File in filelist ('C:\Users\innas\Desktop\Qvd\QV_new\daily\' & FilePath)

You also do not need this line:

SET sFile = '$(File)';


Just use File where you were using sFile.

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Jonathan,

your answer helped very much.

But now while loading I am getting the following error:

Error: File .\extdata.cpp, Line 2788

What can it be?

Thanks.