Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello :);
I want to load a set files excel with same structure in a directory. for this i use this scrpit:
Table1:
LOAD
Field
FROM
Concatenate
LOAD
Field
FROM
My problem is if there are no files in ma directory (xls or xlsx) i have an error, how can i check the presence of a file before start loading.
Best regards.
Sorry the xls and xlsx files are in the same directory c:\Mydirectory\
Hello,
you can use one of the file-funcions. I tested it like that:
LET vMyFS = filesize( 'xyz.xls' );
if ( vMyFS > 0) then
trace --> $(vMyFS);
end if;
Regards, Roland
Think that - for various reasons - it makes more sense to work with
FOR EACH sFileName IN FILELIST('directory & filepattern') ..... NEXT sFileNameScript might be like:
FOR EACH sFileName IN FILELIST ('c:\directory\export_*.xls')
Data:
LOAD * FROM $(sFileName);
NEXT sFileName
IF NOOFROWS('DATA') = 0 THEN
EXIT SCRIPT; // or any other error-action
END IFThanks all for the suggestions! the both solutions worj but i think i will use a file-function (2nd solution).
Thank u very much Roland and Peter.
Sorry i have another qestion,
is it possible after loading the file to move it in another directory ( cut-past)? have i to use windows commandes
Think that's not possible in the script, but you may compare the filenames derived from FILELIST with the already loaded list filenames, and load only those, which are new.
HTH
Peter
Why this commande don't work:
execute copy C:\SrcDirectory\Export_ABM_1.xls C:\TrgDirectory;
Because these are no commands available in QV. Am not sure, whether you may call some external routines out of a script.
++
Peter
This commande work now because i added CMD /C befor 'move':
execute cmd.exe /c C:\Src\export.xls c:\target