Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
Let's say I have the script like:
SET ErrorMode = 0;
tmp:
Load Type
,Number
From [\\FS-03\Data*.xlsx]
;
Set ErrorMode = 1;
Everything reloads well - but in a script log I found a line with an error:
Error: Field not found - <Type>
How should I trace what specific file have just generated this kind of error?
Thank you!
Might be easier to work with FILELIST:
aircode
SET ERRORMODE = 0;
LOAD * FROM $(sFile) ....;
FOR EACH sFile in FILELIST ('\\FS-03\Data*.xlsx')
LOAD * FROM $(sFile) ....;
IF SCRIPTERRORCOUNT() THEN
TRACE Error incurred in $(sFile);
END IF
NEXT sFile
SET ERRORMODE = 1;
not quite sure, whether the TRACE will work this way. But think the way is clear.
Peter
Actually this works as below
If ErrorMode = 1, the script execution stops and it is prompted to user.
If ErrorMode = 0, then script execution simply ignores current statement and follows executing next statements
i am not sure, where you are and what is the use to ErrorMode. Will you explain that? Meanwhile for trace you can try something like below
SET ErrorMode = 0;
tmp:
Load Type
,Number
From [\\FS-03\Data*.xlsx];
Set ErrorMode = 1;
Trace Concat($(ErrorMode), Chr(10));
Exit Script;
I know that the data files I am loading are prompt to errors. To avoid failing the load I just use ErrorMode.
In case I remove ErrorMode it will stop reloading and return me an error of:
That do not provide any useful information.
I just want to know which file fails as I am loading data with a wildcard.
Add
:
FileName() AS FName,
:
to your LOAD statement. Then check what values the field FName contains.
Since your tweaking of ErrorMode will make the LOAD statement skip any erroneous files and proceed to the next, the filenames that are missing from your field FName will either have no rows or missing fields.
Trace Concat($(ErrorMode), Chr(10)) & '[\\FS-03\Data*.xlsx]';
you could use a variable with the excel file loaded at each point
Off course, I made one sample for you with out any error in script and Log file too
Might be easier to work with FILELIST:
aircode
SET ERRORMODE = 0;
LOAD * FROM $(sFile) ....;
FOR EACH sFile in FILELIST ('\\FS-03\Data*.xlsx')
LOAD * FROM $(sFile) ....;
IF SCRIPTERRORCOUNT() THEN
TRACE Error incurred in $(sFile);
END IF
NEXT sFile
SET ERRORMODE = 1;
not quite sure, whether the TRACE will work this way. But think the way is clear.
Peter