Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to import data when file name matches

Hi Friends,

I have month wise data in D drive. Say 09-2014,08-2014 and 07-2014.

How to get the data into qlikview based on the file name.

Thanks


1 Solution

Accepted Solutions
marcarreras
Specialist
Specialist

Hello,

As I don't know your exact purpose, here you have some tools for file management:

If you want to know if a file exists or not:

if filetime('c:\mydata\my.qvd) then

      //qvd exists

else

      //qvd doesn't exist

end if

You can go further the filetime function to control which file you want to import or not, depending of its creation timestamp.

If you want to have a look in a folder:

Directory;

FOR Each File in filelist ('.\BUFFER_*.xlsx')

  LOAD *

  FROM

  '$(File)'

  (ooxml, no labels, table is Sheet1);

NEXT File;

Maybe your solution needs a combination of all these.

Hope it helps.

Marc.

View solution in original post

5 Replies
michielvandegoo
Specialist
Specialist

Use a * as a wildcard instead of the full file name. The files will be concatenated if the fields have identical names.

So for instance:

load .... from 09-2014.qvd; will become

load ... from *.qvd;

marcarreras
Specialist
Specialist

Hello,

As I don't know your exact purpose, here you have some tools for file management:

If you want to know if a file exists or not:

if filetime('c:\mydata\my.qvd) then

      //qvd exists

else

      //qvd doesn't exist

end if

You can go further the filetime function to control which file you want to import or not, depending of its creation timestamp.

If you want to have a look in a folder:

Directory;

FOR Each File in filelist ('.\BUFFER_*.xlsx')

  LOAD *

  FROM

  '$(File)'

  (ooxml, no labels, table is Sheet1);

NEXT File;

Maybe your solution needs a combination of all these.

Hope it helps.

Marc.

View solution in original post

Not applicable
Author

Please explain the second code.

lets I have a file name AAA.txt and BBB.txt. can I  load each based on the above code??

michielvandegoo
Specialist
Specialist

Load with a wildcard (*):

*.txt will load both files and concatenate the same fields.

marcarreras
Specialist
Specialist

In case you want to load every txt file in this folder, do:

load ... from *.txt;

In case you need to load both files but you can not asure they exist, do:

if filetime('AAAA.txt') then

      load * from AAAA.txt;

end if

if filetime('BBBB.txt') then

      load * from BBBB.txt;

end if