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: 
Not applicable

Getting name from a list of csv files

Hi,

I need to load a list of csv files to qvds.

So I am doing it with a loop.

The issue is that every qvd has to have csv name in an appropriate order.

For example, I have ra_daily_2012-10-01.csv and ra_daily_2012_10_02.csv.

So I have to get  ra_daily_2012-10-01.qvd and  ra_daily_2012_10_02.qvd .

So how do I do an appropriate variable?

Thanks.

1 Solution

Accepted Solutions
erichshiino
Partner - Master
Partner - Master

Hi,

You can use this insted of set vFileName, use both lines below:

letvFileBaseName = SubField( File,'\',SubStringCount(File,'\')+1);
letvFileName = left ( vFileBaseName,FindOneOf(vFileBaseName, '.', SubStringCount(vFileBaseName, '.'))-1);

File contains full path and filename

vFileBaseName will contain the full file name ( 2012-10-01.csv)

vFileName will remove the file extension.

(the expression is a bit long to make sure that only the string after the last '.' is removed)

Hope it helps,

Erich

View solution in original post

5 Replies
erichshiino
Partner - Master
Partner - Master

Hi,

Is there a special requirement to read them in this specific order and in a loop?

You can avoid the loop using wild cards to read your .csv.

The syntax would be something like this:

Table:

Load *

from FOLDER\*.csv (txt) ;

Hope it helps,

Erich

Not applicable
Author

Hi,

I am doing something like :

SET FilePath='*.csv';

set vFileName = 'file';



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

TRACE File = $(File);

   
SET sFile = '$(File)';

   
Directory;

   NetworkDomainDailyData:

   
LOAD *

   
FROM

    [$(sFile)]

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



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

drop table NetworkDomainDailyData;



   
next File

So what has to be in 

set vFileName = ?

Thanks!!!

erichshiino
Partner - Master
Partner - Master

Hi,

You can use this insted of set vFileName, use both lines below:

letvFileBaseName = SubField( File,'\',SubStringCount(File,'\')+1);
letvFileName = left ( vFileBaseName,FindOneOf(vFileBaseName, '.', SubStringCount(vFileBaseName, '.'))-1);

File contains full path and filename

vFileBaseName will contain the full file name ( 2012-10-01.csv)

vFileName will remove the file extension.

(the expression is a bit long to make sure that only the string after the last '.' is removed)

Hope it helps,

Erich

Not applicable
Author

Hi,

you really helped me!

Thanks a lot.

My model works:)

Anonymous
Not applicable
Author

Hi Erich,

Can You Please expalin how the FIle Variable will load file path and File Name.

I have more than 100 Excel files in one folder.