Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I know it's possible to load pictures into QlikView. I'm not sure how right now since I haven't been working much with QlikView for a while now. The tool is not very much in focus these days.
Now, however, I have a task that I could very well use it for: I just need to load pictures saved with the .jpg ending - about 23.000, all with a seven-digit number as filename (like >> #######.01.jpg <<) - there are some with >> #######.02 << when the original ppt has two slides.
There is the task now to add to that seven-digit number another two digits, so the new format will be >> #########.01.jpg << - nothing else. I just have to load the files and save them again with the new name - the additional two digits aren't always the same, they have to be taken from another source, but that should not pose a problem.
I know right well that there are quite a lot of specific little tools for this task which would probably be faster because just renaming a file is logically faster than loading and saving it. The thing is that installing any kind of software in this company necessitates a rather lengthy process of checking and releasing by IT on different levels. So it would probably be easier to just do it with the tools we have. Runtime is not very critical as this will have to be done only once.
Can you tell me what would be the fastest way of doing this?
Thanks a lot!
Best regards,
DataNibbler
I have another idea - you need a sleep-statement within your loop to give the system/network time to rename before the next execution comes - quite the same like by printing pdf's in a batch-routine where I use WaitForIdle.
sleep 1000; // = 1000 milli-seconds
Try to play with a few delays - at first a bit longer and then shorter whereby stable working is more important then the run-time.
- Marcus
Hi Marcus,
that's a good idea. I don't even have the EXECUTE stuff for now (I deactivated it), so the problem with my loop is something different for sure, but I will still insert this. Maybe that helps, who knows.
Then, maybe it's a general instability in reading from jpg files or the LOAD doesn't work correctly because there is no identifier following the FROM?
Another point I think of is checking the file-names and/or other parts like your conditions if they are really identical even if they look so - I mean applying functions like len(), keepchar(), trim() and so on to make sure that there are no garbage or unexpected chars anywhere.
Further insights could you get if you applied a logging on the execution of the cmd-statement which will silently fail if there are any errors. For this you could append a >> logfile.log to the cmd-statement, see here an example: Re: Question regarding EXECUTE cmd.exe
- Marcus
Hi Marcus,
that is also good - but for now I have nothing about that cmd at all - it's all deactivated for now, I'm still working on getting the loop itself to run properly.
I'll introduce that SLEEP statement and I'll try loading the filename from the first few files individually to see if there is any difference, even if I don't see any - QlikView cannot load jpg files, but then I only want to load the filename, that's why I don't think I need any identifier.
The strange thing is that it worked with the 10 files I used for testing this ...
Hi Marcus,
I have found something very strange.
I don't really need an identifier in the LOAD when I just want to load the filename - BUT:
- I can load the filename ok from the 1st, 2nd, 3rd, 4th file
<=> From the 5th file, using the exact same method, the filename cannot be loaded.
Do you have any idea what might be the reason for this? They sure look the same - they are jpg files and the filename is formatted the same.
P.S.: I'm beginning to get the impression that, even if I don't have an inkling why, QlikView might after all be the wrong tool for this ... I could try to do the same using VBA code. That is also possible. The only limitation is the fact that my workday is not much longer than anyone else's and I am alone ...
The storage on which your routine tried to grab the files is a windows-server? Then NAS storages aren't supported and lead often to strange and unpredictable results with qlikview.
If you want respectively really need to change the tool might be this vba code-snippet from one of my qv excel-preparations helpful:
Set fso2 = New FileSystemObject
Set fol2 = fso2.GetFolder("YourFolderPath")
For Each subfol In fol2.SubFolders
For Each fil2 In subfol.Files
If Len(fil2.Name) = 14 Then GB = Mid(fil2.Name, 8, 3) Else: GB = Mid(fil2.Name, 8, 4)
If GB = Shop_Z And fil2.Name Like "*.xls" Then
Application.DisplayAlerts = False
Workbooks.Open fil2.Path, ReadOnly:=False 'True
Application.DisplayAlerts = True
Datei = True
End If
Next fil2
Next subfol
- Marcus
Thanks!
Hmm ... you say NAS aren't supported? Do you think it would work if I copied packages of 100 or so files onto my local HDD?
Worth a shot, I guess ...
Nope - copying the whole thing onto my local HDD didn't change things, either. It's still the same - the first four files are loaded correctly and when my routine reaches the 5th, it does not load anything and the "records fetched" remains the same.
I really don't understand this. But I think now I'm going to try to do the same using VBA. There is something about this that seems to be impossible using QlikView. Let's see ...
Thanks for all the help!
Best regards,
DataNibbler
If I look again on your script provided yesterday in post from 16:48 I see that you tried to load image-file directly within a load-statement without to specify a file-format (at least something like this will be needed: (fix, utf8); ).
But this isn't necessary. All your needed informations could you get if you applied your string-functions on your loop-variable $(File) like:
LOWER('$(File)') as Dateiname_alt,
...
Autogenerate 1;
- Marcus
Hi Marcus,
hmm ... you mean I could do without an actual LOAD, or at least without a FROM part?
That might help. Let's see. I'm still a bit unwilling to admit that QlikView just cannot do this without understanding why QlikView should not be able to do it.
I'll try.
P.S.: Would you mind flattening this out into the entire code I'd need (based on what I posted earlier)?