Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have made a copy of a directory on the server containing about 45.000 files, most in jpg format, some different and I want to run a script to loop over all these and just record the filename for once - I will go from there.
For some reason, the code I have doesn't work - it looped over all the files, I could watch it in the progress_window - but I see only BLANKs in a listbox.
The code is like this
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Zunächst laden wir eine kleine Dummy-Tabelle
Dateinamen:
FIRST 1 LOAD
' ' as Dateiname_alt
RESIDENT Fin_Bew
;
DIRECTORY 'C:\Users\friedrich.hofmann\Documents\QS_IdentBilder\Sicherungskopien_20160126\';
FOR EACH File in FileList('*')
Concatenate (Dateinamen) FIRST 1 LOAD '$(file)' as Dateiname_alt AutoGenerate 1;
NEXT File
STORE Dateinamen INTO 'C:\Users\friedrich.hofmann\Documents\QS_IdentBilder\Metadaten\Gesamtliste\Alle_alle.qvd';
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
So I loaded a small dummy_file to concatenate to in each iteration of the loop - so I have one record too much, I can get rid of that lateron - and then I start the loop and for every file I encounter, I just want to load the file_name_and_path.
Can anyone help me find out why this isn't working?
Thanks a lot!
Best regards,
DataNibbler
As I mentioned, can't reproduce:
Well, looking at the error message, QlikView tries to load the file with a truncated name - it just ignores the brackets and looks just for the filename before which of course it does not find - so when the filename is
>> mydifficultfile (200mm).ppt <<, the code looks for >> mydifficultfile << and fails because that does not exist ...
In the following lines, though, the error_message repeats the code it was executing (the LOAD), and that is correct ...
Have you tried to step through your code to see which statement is thowing the error? Where are you trying to load or access this file? I can't reproduce that filelist('...') is throwing an error.
What happens if you add double-quotes or square-brakes like:
LOAD '"$(File)"' as FileName
LOAD '[$(File)]' as FileName
I have both. I simply attach the error_message I am getting, maybe that will help you help me 😉
Sorry, but the error_message is quite long, there is a scrollbar, but I couldn't move it or enlarge it to get it all into one screenshot, so there are three of them - a, b and c.
No need to load from the file itself, just use autogenerate 1.
edit:
And if you need to load from the file (you don't in your scenario shown), use
LOAD '$(File)' as FileName
FROM [$(File)];
Could it be that the whole path is too long - copy your stuff into a new folder like: C:\LoadTest and try it again.
- Marcus
Nope - I copied it to my C drive, but it still returns the same error_message upon trying to load the same file.
Then try the suggestion from Stefan with:
LOAD '$(File)' as FileName autogenerate 1;
That last response by swuehl did the trick (combined with yours) - by using Autogenerate (I had that before, but it's seemingly different now), it worked.
I switched the script back to that longer path I had before because copying that whole heap of files would take quite a while, but if that doesn't work, then I will copy it all to a shorter file_path.
I hope this is going to work now.
Thanks a lot!