Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

FileName() Function Limitations?

I try running the following LOAD in Qlikview:

Images:

LOAD

FileBaseName() as BaseName,

FileName() as ImageFile,

FileExtension() as Extension

From D:\QlikView\Images\*;

Against this folder:

2014-02-19_1055.png

and i get the following result:  SO my Question is: Can filename function not read anything besides .jpg adn .xls files? Why is it missing so many files?

2014-02-19_1056.png

1 Solution

Accepted Solutions

Re: FileName() Function Limitations?

How may rows did you get? Wen I try your code against a folder with 22 files, I get all extensions -- but 36K rows. The default format spec is "(txt)" so each file may generate multiple rows whilst the LOAD is searching for newline chars.

In your case of the missing files, I'll bet something that looked like an EOF was encountered before any "row" was read.

In any case, your hunch is right. This is not a valid technique to collect filenames from a directory. For that, use FOR EACH IN FILELIST() as you suggested.

-Rob

http://masterssummit.com

8 Replies
MVP
MVP

Re: FileName() Function Limitations?

Hi Patrick,

the LOAD statement itself is to load data files or image files (bundle).

- Ralf

MVP
MVP

Re: FileName() Function Limitations?

Can't reproduce your issue, using your code I get a lot of file extensions:

air

cmd

csv

docx

epub

exe

export

gpx

gwc

gz

ics

iso

jpeg

JPG

jpg

kml

kmz

loc

log

mdb

mht

MOV

mov

mp3

mp4

msu

out

p7s

PDF

pdf

pptx

QVD

qvd

qvd (qvd)

qvd (txt)

qvw

qvx

tex

tgz

txt

WAV

wav

wsdl

xls

xlsm

xlsx

xml

zip

You can also consider using FOR EACH file in FILELIST instead of the wildcard search in the FROM.

Not applicable

Re: FileName() Function Limitations?

Hi Ralf,

Essentially I am trying to build a template where you could drop image files and they will display by looking up certain named files and place them in the right place.  Then I call the image in a text object like '$(vLogoFile)'. Right now it works for any image as long as it is a .jpg, but the pull doesn't recognize .png or .gif files.

So i didnt think i need to bundle the actual images just look up and reference the names and paths, but do you think bundling would give better results?

Images:

LOAD

FileBaseName() as BaseName,

FileName() as ImageFile,

FileExtension() as Extension

From D:\QlikView\Images\*;

LET vLogoFile =  lookup('ImageFile', 'BaseName','TitleBarImage');

Not applicable

Re: FileName() Function Limitations?

Strange that you couldnt replicate but in noticed the only image type extension coming up in your list is jpg, JPEG, and jpeg.


No png, no gif, no bitmap etc, maybe they are not supported?

I will try the FOR EACH in FILELIST and see if that makes it any better.

Thanks

MVP
MVP

Re: FileName() Function Limitations?

I would use bundle as a last load instead. Then you can move or deploy the QVW with no disconnected image.

Re: FileName() Function Limitations?

How may rows did you get? Wen I try your code against a folder with 22 files, I get all extensions -- but 36K rows. The default format spec is "(txt)" so each file may generate multiple rows whilst the LOAD is searching for newline chars.

In your case of the missing files, I'll bet something that looked like an EOF was encountered before any "row" was read.

In any case, your hunch is right. This is not a valid technique to collect filenames from a directory. For that, use FOR EACH IN FILELIST() as you suggested.

-Rob

http://masterssummit.com

Not applicable

Re: FileName() Function Limitations?

Thanks Rob,

Any idea why i would get not get results for all the functions ( I think they are valid QV functions):

FOR Each File in filelist ('D:\QlikView\Images\*')

LOAD

'$(File)' as Name,

FileSize( '$(File)' ) as Size,

FileTime( '$(File)' ) as FileTime,

FileBaseName( '$(File)' ) as BaseName,

FileName( '$(File)' ) as ImageFile,

FileExtension( '$(File)' ) as Extension

autogenerate 1;

NEXT File

Returns:

2014-02-19_1055.png

MVP
MVP

Re: FileName() Function Limitations?

AFAIR, these functions don't take a filename as argument, but will use the source file of the table load (not existing in your case). Use string functions on the variable like subfield or left/right etc. instead.

Community Browser